<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mehak Saini</title>
    <description>The latest articles on DEV Community by Mehak Saini (@mehaksaini11).</description>
    <link>https://dev.to/mehaksaini11</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F536937%2F77c79e32-e3c9-4135-84f7-68367cd17b58.jpg</url>
      <title>DEV Community: Mehak Saini</title>
      <link>https://dev.to/mehaksaini11</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mehaksaini11"/>
    <language>en</language>
    <item>
      <title>Linux commands</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Sat, 04 Sep 2021 04:45:08 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/linux-commands-2gn</link>
      <guid>https://dev.to/mehaksaini11/linux-commands-2gn</guid>
      <description>&lt;p&gt;Copy the contents of a file to the clipboard&lt;br&gt;
pbcopy &amp;lt; &lt;/p&gt;

&lt;p&gt;This command was a life saver for me. I had a task where I had to copy the configuration file of nginx from production servers and the size was huge.&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>Day 27 of 365 Days of Code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Wed, 14 Apr 2021 10:25:31 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-27-of-365-days-of-code-34n1</link>
      <guid>https://dev.to/mehaksaini11/day-27-of-365-days-of-code-34n1</guid>
      <description>&lt;p&gt;Implemented login functionality for my clone of twitter. Used graphql to make api call from react client to apollo server and passed the login form data. The data was then verified by using findOne and bcrypt.compare method. Need to work on sending an appropriate message to the client on successful login.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>mongodb</category>
      <category>graphql</category>
    </item>
    <item>
      <title>Day 26 of 365 days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Tue, 13 Apr 2021 10:46:49 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-26-of-365-days-of-code-15be</link>
      <guid>https://dev.to/mehaksaini11/day-26-of-365-days-of-code-15be</guid>
      <description>&lt;p&gt;Worked on my side-project, added the signup functionality using apollo client/server functionality and saving the user in mongo db&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>graphql</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Day 25 of 365 Days of Code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Tue, 30 Mar 2021 12:44:46 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-25-of-30-days-of-code-round-1-2p4b</link>
      <guid>https://dev.to/mehaksaini11/day-25-of-30-days-of-code-round-1-2p4b</guid>
      <description>&lt;p&gt;I came across a peculiar problem in my react application. The change handler of an input field was not passing the event object, rather only the value of the field was getting passed. I'm using rsuite and I think it uses Semantic-UI components somewhere, not sure, need to check more on this. Long story short, I fixed it by using the second argument of the handler function, didn’t know that existed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//old version
const handleChange=(event)=&amp;gt;{
      console(event.target) // undefined
      console(event) // value of the object which should otherwise be event.target.value
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//new version
const handleChange=(value, event)=&amp;gt;{
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, I'm changing the challenge name to 30 days of Code. It looks rather achievable :P&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>rsuite</category>
      <category>graphql</category>
    </item>
    <item>
      <title>Day 24 of 365 Days of Code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Mon, 29 Mar 2021 10:37:38 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-24-of-365-days-of-code-1jph</link>
      <guid>https://dev.to/mehaksaini11/day-24-of-365-days-of-code-1jph</guid>
      <description>&lt;p&gt;Added bcrypt module to my application to encrypt the password before storing it to mongoDB. In addition, added the jwt token code logic and store it to the db.&lt;br&gt;
Next Steps: Make a call from client(react) to submit the form and do the validations on the server(graphQL-express) side&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>graphql</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Life saving Git commands</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Thu, 25 Mar 2021 05:22:40 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/life-saving-git-commands-nff</link>
      <guid>https://dev.to/mehaksaini11/life-saving-git-commands-nff</guid>
      <description>&lt;p&gt;If you've committed some files in your local repository by mistake, you can undo it without losing your changes using the below command&lt;br&gt;
1)Don't remove staged files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset --soft HEAD^
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2)Remove staged files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset HEAD^
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to undo commit and lose all the changes, you can use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset --hard HEAD^
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>git</category>
    </item>
    <item>
      <title>Day 23 of 365 Days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Wed, 24 Mar 2021 17:21:26 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-23-of-365-days-of-code-1edc</link>
      <guid>https://dev.to/mehaksaini11/day-23-of-365-days-of-code-1edc</guid>
      <description>&lt;p&gt;Fiddled with jsonwebtoken and bcrypt library of npm. Basically, created a small application to store password in an encrypted format in mongoDB using mongo's pre method. Similarly, made use of mongoose's schema.methods to define a new function and generate jwt token&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>mongodb</category>
      <category>100daysofcode</category>
      <category>react</category>
    </item>
    <item>
      <title>Day 22 of 365 days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Tue, 23 Mar 2021 15:29:28 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-22-of-365-days-of-code-5749</link>
      <guid>https://dev.to/mehaksaini11/day-22-of-365-days-of-code-5749</guid>
      <description>&lt;p&gt;Wrote a blog on JWT. Do check out &lt;a href="https://dev.to/mehaksaini11/why-json-web-tokens-are-required-30f5"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>java</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why JSON Web tokens are required?</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Tue, 23 Mar 2021 15:05:35 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/why-json-web-tokens-are-required-30f5</link>
      <guid>https://dev.to/mehaksaini11/why-json-web-tokens-are-required-30f5</guid>
      <description>&lt;p&gt;JSON web tokens (acronym JWT, pronounced at JOT) were introduced in 2010 as a means of communication between two parties in the form of a JSON object. They can be encrypted and are popularly used over session id in authorisation mechanism in a server client architecture. Let's discuss what has made it so prevalent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Server-Client Architecture
&lt;/h3&gt;

&lt;p&gt;In this scenario, if a client requests a protected page(&lt;a href="https://dev.to/new"&gt;https://dev.to/new&lt;/a&gt;) from a server(by protected I mean the one shielded with some authentication mechanism), the server renders a login page . User( the term client and user are used interchangeably ) enters the user credentials and is successfully logged in. If in a subsequent request, the client requests the same url (&lt;a href="https://dev.to/new"&gt;https://dev.to/new&lt;/a&gt;), server has no way of knowing that it has already authenticated this user and re-renders the login page.&lt;/p&gt;

&lt;h4&gt;
  
  
  Solution1
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Session id
&lt;/h5&gt;

&lt;p&gt;So as a solution to the above problem, the concept of session id was introduced wherein the server creates a new session when a client requests anything for the first time. It then  stores and passes the session id back to the client so that it can identify the client in case of any subsequent requests. Though it is a feasible solution and widely used, it has its own drawbacks.&lt;/p&gt;

&lt;h5&gt;
  
  
  Drawbacks
&lt;/h5&gt;

&lt;p&gt;As the number of requests increase, there is a need for  increased scalability.&lt;/p&gt;

&lt;h5&gt;
  
  
  Vertical scalability
&lt;/h5&gt;

&lt;p&gt;Increase the number of resources for a server. It is an expensive solution&lt;/p&gt;

&lt;h5&gt;
  
  
  Horizontal scalability
&lt;/h5&gt;

&lt;p&gt;Increase the number of servers.&lt;/p&gt;

&lt;p&gt;Though the latter is feasible, the downside is that as you increase the number of servers, you need to put a load balancer in front of it which is responsible for request management. Now, the requests can go to any server irrespective of the client requesting it. So, if a user1 is authenticated with server1 and requests the same page again, and now the request goes to server2, some mechanism is need to tell server2 that user1 is already authentication. Hence, there is a need of storing the session ids in a database or in an alternate solution, keep the servers in sync at all times which comes with its own overhead.&lt;/p&gt;

&lt;h4&gt;
  
  
  Solution 2
&lt;/h4&gt;

&lt;h5&gt;
  
  
  JWT
&lt;/h5&gt;

&lt;p&gt;For servers implementing JWT, there is no need of session storage. When a client requests a protected resource, server creates a JWT token and passes it to the client. JWT can contain user data along with other information in an encrypted format. Server does not store the JWT token, rather it stores the encryption key, so the next time user requests the same resource, server uses the key to decrypt and identify the client.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>jwt</category>
      <category>webdev</category>
      <category>http</category>
    </item>
    <item>
      <title>Day 21 of 365 days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Thu, 18 Mar 2021 15:39:57 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-21-of-365-days-of-code-5fcn</link>
      <guid>https://dev.to/mehaksaini11/day-21-of-365-days-of-code-5fcn</guid>
      <description>&lt;p&gt;Worked with nginx server, mostly setting up custom response headers. Apart from that, got little time for my side node project. Refactored the code. Looks a lot less messy now :P&lt;/p&gt;

</description>
      <category>java</category>
      <category>javascript</category>
      <category>nginx</category>
      <category>node</category>
    </item>
    <item>
      <title>Day 20 of 365 days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Wed, 17 Mar 2021 12:18:24 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-20-of-365-days-of-code-ppp</link>
      <guid>https://dev.to/mehaksaini11/day-20-of-365-days-of-code-ppp</guid>
      <description>&lt;p&gt;Refactored my existing code and started working on another project involving gql, express, mongo, react. Did basic boilerplate setup. &lt;br&gt;
Will soon come up with a blog on JWT sessions.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>mongodb</category>
      <category>java</category>
    </item>
    <item>
      <title>Day 19 of 365 days of code</title>
      <dc:creator>Mehak Saini</dc:creator>
      <pubDate>Tue, 16 Mar 2021 14:26:52 +0000</pubDate>
      <link>https://dev.to/mehaksaini11/day-19-of-365-days-of-code-1c9h</link>
      <guid>https://dev.to/mehaksaini11/day-19-of-365-days-of-code-1c9h</guid>
      <description>&lt;p&gt;Explored three different ways of creating a server&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Apollo server without express middleware&lt;/li&gt;
&lt;li&gt;Apollo server with express middleware&lt;/li&gt;
&lt;li&gt;Vanilla express server using Apollo server dependencies&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
      <category>graphql</category>
      <category>react</category>
      <category>express</category>
    </item>
  </channel>
</rss>
