<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Piyush Garg on Medium]]></title>
        <description><![CDATA[Stories by Piyush Garg on Medium]]></description>
        <link>https://medium.com/@piyushdev?source=rss-ca8430bd188a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*JwPRcVd5Yb0D5pO4ayOlTA.jpeg</url>
            <title>Stories by Piyush Garg on Medium</title>
            <link>https://medium.com/@piyushdev?source=rss-ca8430bd188a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:18:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@piyushdev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrate Razorpay Payment Gateway with node.js and express server]]></title>
            <link>https://piyushdev.medium.com/integrate-razorpay-payment-gateway-with-node-js-and-express-server-924f771af7e0?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/924f771af7e0</guid>
            <category><![CDATA[razorpay]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Sun, 09 May 2021 07:18:25 GMT</pubDate>
            <atom:updated>2021-05-09T07:18:25.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HJx01CV1Lrrpkd6PrHxigA.png" /><figcaption>Source: Razorpay</figcaption></figure><p>Hello reader, in this article I would provide you step by step guide to integrate the <strong>Razorpay payment gateway</strong> into your node.js application. Trust me, it’s easy than you think.</p><p>So, let’s begin…</p><h3><strong>Step 0: Initialize Project</strong></h3><p>First things first, so let&#39;s create a simple project folder and start our journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*bHeoveO3g9yFiQMUJTR0aA.png" /></figure><p>Here I have created a folder named “razorpay-tutorial”. Now open your terminal in the folder and run the following command to init the node server.</p><pre>npm init -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*Ir_HJaa59FZOo_6mZzC_5A.png" /></figure><p>This command would create a package.json file in your project.</p><h3><strong>Step 1: Install dependencies</strong></h3><p>In order to integrate razor pay, we need to install the following dependencies.</p><ol><li>express</li><li>razorpay</li></ol><p>Run the following command to install the above dependencies.</p><pre>npm install express razorpay</pre><h3>Step 2: Create and set up a simple express server</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28b60ef2449d57b0ae5d8e29a1b41e9e/href">https://medium.com/media/28b60ef2449d57b0ae5d8e29a1b41e9e/href</a></iframe><p>also, create a public folder in your project and serve it via express.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*key8Fa2rsSBwBUpobyN46Q.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a673374bb5ef6e0a1a9b474528757ac/href">https://medium.com/media/3a673374bb5ef6e0a1a9b474528757ac/href</a></iframe><h3>Step 3: Let&#39;s begin with razorpay</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--oRnmlvyzhe-ufJjfRqXA.png" /></figure><p>To begin with, firstly we have to create an order on our server.</p><h4>Step 3.1: Creating an order on our server</h4><pre>Note: You need to create an test account on the razorpay. Then in the settings pannel of razorpay, go to API keys and generate keys. Copy the key_id and key_secret.</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6dee113ab2438371b400ff284e46820/href">https://medium.com/media/b6dee113ab2438371b400ff284e46820/href</a></iframe><p>As you can see, we have defined a post route “/order” which is responsible for creating an order and return a JSON response with the created order.</p><h4>Step 3.2 Design our front-end</h4><blockquote>Navigate to your public folder and add the following code to public/index.html file.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/690614b9ea434276bb4233efda29f9b1/href">https://medium.com/media/690614b9ea434276bb4233efda29f9b1/href</a></iframe><p>Now start your server and head to <a href="http://localhost:8000/">http://localhost:8000</a></p><blockquote>Run the following command to start the server</blockquote><pre>node index.js</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*7BRRakHBICJy-SEoz7QhIQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02079cab8c71cb51568b126838681f2a/href">https://medium.com/media/02079cab8c71cb51568b126838681f2a/href</a></iframe><p>In your button click event listener add the above code and done. You have successfully integrated the Razorpay gateway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*tTy72NmPS0K1DKdrgH-jnA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=924f771af7e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a chat application with Express and Socket.io]]></title>
            <link>https://medium.com/daily-programmer/build-a-chat-application-with-express-and-socket-io-e8c335d27386?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8c335d27386</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[socketio]]></category>
            <category><![CDATA[chatbot-development]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 14:45:28 GMT</pubDate>
            <atom:updated>2020-07-21T14:47:19.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u02jO0_Ii1f4OOAtWlcQ-g.png" /></figure><p>Hey guys, In this article, we would be building a real chat application. Building a chat application is really easy.</p><p>For this application, we would be using Express.js and Socket.io.</p><p>I would recommend you to code along with me to better understand the code.</p><h4>So, Let’s begin 😉</h4><blockquote>checkout best laptop for programmers: <a href="https://amzn.to/2WHjAFE">https://amzn.to/2WHjAFE</a></blockquote><h3>Step 0: Setting up the project</h3><h4>Firstly, let&#39;s create a folder chatApp</h4><p>After then create the following two new folders inside the chatApp folder:</p><ol><li>server</li><li>client</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*xU95ozXf9hzM17Ke8moKUA.png" /></figure><h3>Step 1.1: Server</h3><p>Now, head over to the <strong>server folder</strong> and run the following command:</p><pre>npm init</pre><p>After initializing package.json lets now install some dependencies</p><pre>npm install socket.io</pre><h4>Great, and finally let&#39;s create our index.js file</h4><h4>Now, let&#39;s have our boilerplate code to server/index.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b28e1afdab3ef6d03e8972c076386b7/href">https://medium.com/media/0b28e1afdab3ef6d03e8972c076386b7/href</a></iframe><p>In the above code firstly we required the node’s build-in HTTP module and created a server using <strong>createServer()</strong> method.</p><p>Then, we imported our <strong>socket.io</strong> and named it as socket which returns a function.</p><p>Finally, we initialised our io by calling the function socket and passed our server as parameter to it.</p><h4>Great, now we have successfully created a server and initialized our io.</h4><h3>Step 1 Creating socket.io listeners on the backend</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7733f59c7bb7d712b482e3c315a5b0d1/href">https://medium.com/media/7733f59c7bb7d712b482e3c315a5b0d1/href</a></iframe><p>Whenever there is a new user or a connection joins the chat, the <strong>‘connection’</strong> event is fired by the <strong>socket.io</strong>, to which we are listening with the<strong> .on method</strong>.</p><p>so <strong>io.on(‘connection’), </strong>means whenever there is a connection this function will be called. This function has a second argument which is a callback function that has access to a single parameter and that is a socket. The socket contains information about the user who has just joined.</p><p>So whenever a new user joins the chat, our server would log <strong>A new user has joined the chat. </strong>Also, we must welcome the user who has just joined by saying, <strong>You have successfully joined the chat.</strong></p><p>So, to send a message <strong>only to a particular user who has just joined</strong> we do:</p><pre>socket.emit(&#39;message&#39;, &#39;<strong>You have successfully joined the chat&#39;);</strong></pre><p><strong>.emit</strong> method is used to fire up an event where the first parameter is event name and second is the data.</p><p>With that being set now let us set up our listeners for the incoming and outgoing chat messages.</p><p>So to listen to an event we use the <strong>.on method.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5df8597a36da218d2c14a584ce849ba5/href">https://medium.com/media/5df8597a36da218d2c14a584ce849ba5/href</a></iframe><p>Let me simplify, In the above code, we are listening to an event named as “message” which would be fired up from our frontend later. So whenever a socket ( which is a user ) sends a message we will take that message and send that to everyone. The io means everyone.</p><blockquote><strong>socket.emit</strong> — Only to the user.</blockquote><blockquote><strong>IO </strong>— To all the users connected to our application.</blockquote><h4>I hope you got the point. 🤓</h4><p><strong>Now Run your server:</strong></p><pre>node index.js</pre><p><strong>and keep it running…</strong></p><h3>Good News! 🎉Our backend is complete. Yes! That&#39;s it.</h3><h3>Step 1.2: Creating FrontEnd</h3><h4>Now, navigate to the client folder and create index.html and index.js file.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*3XiPtDpIthKb7a4pkG2lZA.png" /></figure><p>Now, let&#39;s design a simple frontend in index.html</p><h4>Copy the code below into index.html</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fad624cdbdc445c563a27a1d3e1f5fdf/href">https://medium.com/media/fad624cdbdc445c563a27a1d3e1f5fdf/href</a></iframe><p>Our Design</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYkJHYBdSmOkWvDX_nxuzw.png" /></figure><h3>Now navigate to index.js file in the client folder</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/564b952b98a3779358d8b561da661ab3/href">https://medium.com/media/564b952b98a3779358d8b561da661ab3/href</a></iframe><p>So firstly we initialize our socket variable and pass our servers address.</p><p>Then, we listen to the message event fired by our backend which contains the message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*E5q1V9SBiTXFdCsW2IZlQQ.png" /><figcaption>server/index.js: Rember this?</figcaption></figure><p>And finally, we add an event listener to our form and emits the user message to a socket which is being listened by our backend.</p><h3>Now, on the vscode, run the index.html with live server and test the application</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-6XGQxgEpeKxji3KmX4EA.png" /><figcaption>Ohh! I got a welcome Message</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*dM7VmKmYcISN8Gt9aZyJqA.png" /><figcaption>Also, my server says that</figcaption></figure><h3>Congrats! You have successfully build your own chatting server.</h3><h4>Also checkout best laptop for programmers: <a href="https://amzn.to/2WHjAFE">https://amzn.to/2WHjAFE</a></h4><ul><li><a href="https://medium.com/daily-programmer/authentication-in-nodejs-using-passport-js-48b3c7394a5d">Authentication in Nodejs using Passport.js</a></li><li><a href="https://medium.com/daily-programmer/express-and-mongodb-78cc7266f569">Express and MongoDB</a></li><li><a href="https://medium.com/daily-programmer/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a></li><li><a href="https://medium.com/daily-programmer/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></li></ul><h3>Social Links:</h3><p>Github: <a href="https://github.com/piyushgarg195">https://github.com/piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">https://www.linkedin.com/in/piyushgarg195/</a></p><p>Website: <a href="https://www.piyushgarg.dev/">https://www.piyushgarg.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8c335d27386" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/build-a-chat-application-with-express-and-socket-io-e8c335d27386">Build a chat application with Express and Socket.io</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Express and MongoDB]]></title>
            <link>https://medium.com/daily-programmer/express-and-mongodb-78cc7266f569?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/78cc7266f569</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[mern]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Sat, 25 Apr 2020 13:19:06 GMT</pubDate>
            <atom:updated>2020-04-25T13:19:06.449Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LkuGhCYJ7ZcXYVGaK1WHBw.jpeg" /></figure><p>Hey there, In this article, I would be teaching you how to use <strong>MongoDB</strong> with express.js and perform CRUD operations.</p><h3>What is MongoDB?</h3><p>MongoDB is a no-SQL database. It is a general-purpose, document-based, distributed database built for modern application developers and for the cloud era.</p><h4>MongoDB stores the data as form of document inside collections.</h4><p>For Example: If I have a record of 5 students, So I can say that I have 5 documents inside a collection named as students.</p><h4>I hope you got the point. 😄</h4><blockquote>Note: In this tutorial, I will be using MongoDB atlas to avoid the complexities faced while installing MongoDB and it would also be easier for beginners to understand too.</blockquote><blockquote><strong>MongoDB Atlas is a cloud service to use mongoDb.</strong></blockquote><h3>Let’s Begin</h3><h3>Step 0: Create an account on MongoDB</h3><p>Head over to <a href="https://www.mongodb.com/">https://www.mongodb.com/</a> and create your free account to use MongoDB atlas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W2rovHt2L4VmclNLtbZ6RQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*O75hinSk5C61gz0p76g3MA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZdOVOU7rosTv01OfBSH-A.png" /></figure><h3>After creating your account, choose free cluster and click on create a cluster</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fzXoa7ftzElgnV3-T3bEvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YYngQkgymod2gvYGhdHd-A.png" /></figure><h3>Now, wait for 2–3 minutes for the cluster to get deployed.</h3><h3>Congrats! You have successfully deployed your cluster and now we are ready to move on to next step. 🎉</h3><h3>Step1: Configuring MongoDB Atlas</h3><p>There are a couple of tweaks here and there which we need to follow to get started with MongoDB Atlas.</p><h4><strong>Creating a user role to access the database from our application</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3CNtgNdgTSiQMx9Ku6Fh4w.png" /><figcaption>Navigate to Database Access</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KovWzAEa41RBVJrQ09qw6g.png" /><figcaption>Click add new database user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*vgiKpd1L6whAJZ41DSDAEA.png" /></figure><h4>Now, We have to whitelist the IP’s from where we can access the database.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9aLp5sXMGRb3sGzC-j0ew.png" /><figcaption>Navigate to Network access and click Add IP Address</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*QJyT-uBvamJVtrMNUDeAfA.png" /><figcaption>Select Allow Access from anywhere and select confirm</figcaption></figure><h3>Step 2: Project Setup</h3><p>Now, lets set up our project structure and create boilerplate code.</p><h4>Firstly, create a folder. Let&#39;s name it as “myProject”.</h4><h4>Now, Fire-up your terminal or command prompt and run:</h4><pre>npm init</pre><h4>Great, Now let&#39;s install dependencies.</h4><p>Run:</p><pre>npm i express mongoose</pre><p><strong>Great Going, Now let&#39;s create some files and folders. For the time bear with me and create these folders. I am going to explain the working of each and file step by step.</strong></p><p><strong>Our Project Structure:</strong></p><pre>myProject<br>|<br>|- model<br>     |- user.js<br>|- index.js<br>|- package.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*-czPNA76-2E1c6eEU5ik8Q.png" /></figure><p>In the above project structure, we have created a folder <strong>model, </strong>this is the folder where we are going to keep all our schemas for different collection.</p><p>Currently, we have one, the <strong>user.js</strong></p><h3>Step 3: Creating the Boilerplate Code</h3><p>Head over to index.js and code along with me.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8361751e8de1a7e377a9ffaae76b1ec5/href">https://medium.com/media/8361751e8de1a7e377a9ffaae76b1ec5/href</a></iframe><h3>Step 4: Connect our node application to MongoDB Atlas</h3><p>Connecting application to MongoDB is really simple.</p><ol><li><strong>Head over to Clusters panel and click connect.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V46_lxAnTQDdXmWP9G0HdA.png" /></figure><p><strong>2. Click on connect your application.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*Q3a1Aqj_eXOKh7m2YQlMlA.png" /></figure><p><strong>3. Copy the connection string</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*riM-oVeMe3gnngPQFqutqA.png" /></figure><p>Great Now back to our code …..</p><h4>Follow the steps below to connect to MongoDB Atlas</h4><ol><li>Import the mongoose package in index.js</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3400399d8626a56dd4aae159ce24c574/href">https://medium.com/media/3400399d8626a56dd4aae159ce24c574/href</a></iframe><p>2. Use connect function of mongoose to connect to our application and pass the connection string that we copied earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*zg3cWYfavn06yb2vtvGx7g.png" /><figcaption>Replace the original password with &lt;password&gt;</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b65add494a403fe006fab4d05027245/href">https://medium.com/media/6b65add494a403fe006fab4d05027245/href</a></iframe><p>Additionally, pass the following parameters to the connect function:</p><blockquote>Refer to <a href="https://mongoosejs.com/docs/deprecations.html">https://mongoosejs.com/docs/deprecations.html</a> for more info</blockquote><pre>{</pre><pre>useNewUrlParser: true,</pre><pre>useUnifiedTopology: true</pre><pre>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3fa24f1289124fd0b0b755f73dbaa40/href">https://medium.com/media/c3fa24f1289124fd0b0b755f73dbaa40/href</a></iframe><h3>Congrats! 🎉… try running the server and you would see MongoDB connected on the console.</h3><h3>Step 4: Creating user schema</h3><p>In this step, we would be working with the <strong>user.js</strong> inside our <strong>models</strong> folder and create a user schema.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d857dfb08c5aece9bcffe23645b21354/href">https://medium.com/media/d857dfb08c5aece9bcffe23645b21354/href</a></iframe><p>In this file, we, first of all, require the mongoose package and then use the . Schema method to create the schema. In the Schema method, we pass an object specifying our schema of the user with various properties like type, unique and required.</p><p>Finally, we create a model using mongoose. model which requires two parameters:</p><p>First: The name of the model as a string. [ users ]</p><p>Second: The user schema we created above.</p><h3>Hooray! User Schema Ready! Now we are ready to perform CRUD operations</h3><h3>Step 5: API and CRUD operations</h3><p>In this step, we would be creating API&#39;s to perform crud operation on our DB.</p><p>Back to index.js</p><h4>Import the user.js and start coding along with me.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5727506f095bc85e821d51a57fed2a80/href">https://medium.com/media/5727506f095bc85e821d51a57fed2a80/href</a></iframe><p>There is one error in code and that is we have not implemented the express.json() middleware.</p><p>Well, that’s your task.</p><h3><strong>And Done! 😍</strong></h3><h3>Let&#39;s test our implementation in Postman</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*k0YEgs3tmkGKEdpCEsWkEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*iR3xwD-FjYEf3nhUTlEvSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*MowkmYFtb_vUYOWKh34glg.png" /></figure><h4>In your MongoDB Atlas go to collections and see your newly created user document there.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*oNM2qgsviEjpQ861CCmqiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*O_lGkWGSDROAj59RtY9koA.png" /></figure><h3>Great! 😍 Our API is working great.</h3><ul><li><a href="https://medium.com/daily-programmer/authentication-in-nodejs-using-passport-js-48b3c7394a5d">Authentication in Nodejs using Passport.js</a></li><li><a href="https://medium.com/daily-programmer/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a></li><li><a href="https://medium.com/daily-programmer/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></li><li><a href="https://medium.com/daily-programmer/authentication-in-nodejs-using-json-web-tokens-jwt-936e6c0118ef">Authentication in Nodejs using JSON web tokens (JWT)</a></li></ul><h3>Social Links:</h3><p>Github: <a href="https://github.com/piyushgarg195">https://github.com/piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">https://www.linkedin.com/in/piyushgarg195/</a></p><p>Website: <a href="https://www.piyushgarg.dev/">https://www.piyushgarg.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78cc7266f569" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/express-and-mongodb-78cc7266f569">Express and MongoDB</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication in Nodejs using Passport.js]]></title>
            <link>https://medium.com/daily-programmer/authentication-in-nodejs-using-passport-js-48b3c7394a5d?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/48b3c7394a5d</guid>
            <category><![CDATA[passportjs]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Fri, 24 Apr 2020 18:16:47 GMT</pubDate>
            <atom:updated>2020-04-24T18:21:11.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rQKEH9NN2iDbjbxT-LSfw.png" /></figure><p>Hello once again, In this article I would be teaching you <strong>authentication in nodejs</strong> using <strong>express and passport.js</strong></p><p>I know working with passport.js is a little bit tricky and confusing, but trust me I&#39;ll make it really simple.</p><p>I would highly recommend you to code along with me to better understand the flow of the code.</p><h3>Note: Before we begin I would like you to understand the term “Strategy”</h3><p>Passport uses what is termed <em>strategies</em> to authenticate requests.</p><p>Like authenticating with username and password is a strategy, authenticating with google or Facebook is a strategy.</p><p>So the strategy is a way to authenticate a user.</p><p>In this tutorial, we would be using the username and password authentication known as a <strong>local strategy</strong> in terms of passport.js</p><h3>Step 0: Project setup and Installing dependencies</h3><p><strong>First of all, Create a new folder, let’s say “myApplication” and open your terminal or command prompt in that folder.</strong></p><p>After opening your terminal or command prompt run the following command to initialize your node application.</p><pre>npm init</pre><h4>After successfully creating your JSON file, now we are ready to install the following dependencies:</h4><ol><li>express</li><li>express-session</li><li>passport</li><li>passport-local</li></ol><h4>Install the above dependencies by typing following command:</h4><pre>npm install express express-session passport passport-local</pre><h4>Now, Our project is set up and we are ready to move to the next step.</h4><h3>Step 1: Creating a Boilerplate Code</h3><h4>Lets now create index.js and write the boilerplate code for the express app.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/143012d001b272639a42ae0a29a977ea/href">https://medium.com/media/143012d001b272639a42ae0a29a977ea/href</a></iframe><h4>So, I hope that you have got an idea that what we are going to implement.</h4><h4>In the above code we have two routes:</h4><ol><li><strong>Home Route ‘/’: </strong>This route checks if the req.user is present, which means the user is logged in and sends <strong>heyy and email</strong> if so, else it sends a response saying<strong> Heyy how are you?.</strong></li><li><strong>Login Route ‘/login’:</strong> This route is a route that we need to implement later. This route is responsible for logging in the user.</li></ol><h4>Now, in the next step, we would be implementing some middleware functions which we need to authenticate the user.</h4><h3>Step 2: Implementing Middleware functions</h3><h4>To authenticate our user using passport we need to implement the following middleware functions:</h4><ol><li><strong>express-session() — Maintaining Sessions</strong></li><li><strong>passport.initialize() — Initialize Passport.js</strong></li><li><strong>passport.session() — Using Passport Sessions</strong></li></ol><p>With that being set lets import and implement them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d1eee4f46c7d73238f43d00c4193a45/href">https://medium.com/media/8d1eee4f46c7d73238f43d00c4193a45/href</a></iframe><h3>Okay, With that being set let&#39;s move to next step.</h3><h3>Step 3: Code the passport.js</h3><p>In this step, we would be coding the logic part of passport.js which is really simple.</p><p>Step 1: Create a file named as <strong>passport.js</strong> in your project root directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*bqeM5BkpUv4cYPT_LqLKgQ.png" /></figure><p>Step 2: Import <strong>passport-local</strong> Strategy</p><pre>const LocalStrategy = require(&#39;passport-local&#39;).Strategy;</pre><p>Finally exporting a helper function that accepts passport as a parameter and configures it as a local strategy for us.</p><p>It okay for now if you didn&#39;t understand the above line.</p><h4>So our passport.js would look something like this:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a929d84386ca71fe6bebed951d1339f/href">https://medium.com/media/7a929d84386ca71fe6bebed951d1339f/href</a></iframe><h4>Let me simplify the above code</h4><p>In the above code, we are exporting a function that takes passport as a parameter(line #3), After then it calls the use method on the passport that we get from the parameter and passes a new instance of the strategy we want to use (local strategy in this case, the one we imported on the top).</p><p><strong>The LocalStrategy instance which is being passed to passport.js(line #5) takes in two parameters:</strong></p><ol><li><strong>Options:</strong> We are passing an option{usernameField: ‘email’, passwordField: ‘password’}, which means that the user would provide his username with a field named as email and password with field named as password.</li><li><strong>callback function:</strong> The second argument is a callback function which has access to 3 parameters:</li></ol><ul><li><strong>email:</strong> Email Id of the user</li><li><strong>password:</strong> Password of the user</li><li><strong>done</strong>: We call the done function after we process our logic with email and password to call next middleware.</li></ul><p>If we found the user from database and we match the password we call done function with the first parameter as null and second as user object.</p><pre>done(null, user);</pre><p>If we could not found the user or the password is wrong we call the done function as:</p><pre>done(null, false, {message: &quot;Incorrect Password or no user found&quot;}</pre><h3>Step 4: Completing our login route</h3><p>Before we complete our login route we need to configure our passport js with the help of function we just created in the previous step.</p><p>Back to index.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d13a1ec64347a68dc6dc75bf632e3382/href">https://medium.com/media/d13a1ec64347a68dc6dc75bf632e3382/href</a></iframe><p>After we configure the passport, lets now complete our login route</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7312812a7aa6903675fd9e225ad22e3/href">https://medium.com/media/c7312812a7aa6903675fd9e225ad22e3/href</a></iframe><h4>Yeah! That&#39;s it. Your Login route is ready.</h4><p>The passport.authenticate(‘local’) would call the function we exported from passport.js and pass the email and password to the Local Strategy we created.</p><p>If everything goes well, passport then called the next middleware that is our req, res function where we send a response saying login success.</p><h3>Last Step: Serialize and Deserialize the user</h3><p>Don’t panic! Serialising and the deserializing user simply means that every time the user makes a request to the server we need to parse the incoming user and set the user value to the req.user object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca5ee4a3ff07836b1ae28a049f51f271/href">https://medium.com/media/ca5ee4a3ff07836b1ae28a049f51f271/href</a></iframe><p>Every time the user makes a request to server firstly the Serialize user gets called which has the user that we created before. (passport.js line number #12).</p><p>Then this function further calls the deserialize user in which we set the req.user and pass the control to next middleware.</p><h3>Congrats! You have learned how to implement authentication using Passport.js</h3><h3><strong>Let&#39;s test our implementation in Postman</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-KYC-UKQC1GxPq35AaTrIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7sLkh2lVmC9hf9MmzDd1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdUbFiE_61UAmfikkOI5qw.png" /></figure><ul><li><a href="https://medium.com/@gargpiyush195/authentication-in-nodejs-using-json-web-tokens-jwt-936e6c0118ef">Authentication in Nodejs using JSON web tokens (JWT)</a></li><li><a href="https://medium.com/@gargpiyush195/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a></li><li><a href="https://medium.com/@gargpiyush195/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></li></ul><h3>Social Links:</h3><p>Github: <a href="https://github.com/piyushgarg195">https://github.com/piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">https://www.linkedin.com/in/piyushgarg195/</a></p><p>Website: <a href="https://www.piyushgarg.dev/">https://www.piyushgarg.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48b3c7394a5d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/authentication-in-nodejs-using-passport-js-48b3c7394a5d">Authentication in Nodejs using Passport.js</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 Libraries for Reactjs]]></title>
            <link>https://medium.com/daily-programmer/top-5-libraries-for-reactjs-42062f812c75?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/42062f812c75</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 18:51:23 GMT</pubDate>
            <atom:updated>2020-04-23T18:51:23.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NXFsNVa_P4bgum9DSTZgMQ.png" /></figure><p>In this article, I would be listing the top 5 libraries for React that can make your life easier.</p><h3>1. Ant Design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxnhKeU8CcAV_fgQn3KTDA.png" /></figure><p><a href="https://ant.design/">Ant Design</a> is a design system for enterprise-level products. Create an efficient and enjoyable work experience. It offers tons and tons of components with very powerful features.</p><h3>2. React Bootstrap</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OJAtgdFnb5Uq0W_NsMv0GA.png" /></figure><p>The <a href="https://react-bootstrap.github.io/">React Bootstrap</a> library is exactly what the name describes: Bootstrap components built with React. Bootstrap is an open-source toolkit for developing with HTML, CSS, and JS. Bootstrap is the world’s most popular front-end component library.</p><p>What is great about React Bootstrap is that it replaces the old Bootstrap JavaScript. Each component in this library has been built from scratch as a true React component, without unneeded dependencies like jQuery.</p><p>As one of the oldest React libraries, React Bootstrap has evolved and grown alongside React, making it a great choice as your UI foundation.</p><p>Source: <a href="https://medium.com/u/9a5b40458190">Daan</a></p><h3>3. React Spinners</h3><p>There is no space any longer for boring spinners in your applications. <a href="https://www.react-spinners.com/">React spinner</a> is a library that offers a wide variety of fancy spinners. The properties of these spinners can be tweaked so you can fully customize the spinners the way you want.</p><p>This is a small library that has about 1k stars on GitHub, but it could give your application a real boost in terms of UX.</p><p>Source: <a href="https://medium.com/u/9a5b40458190">Daan</a></p><h3>4. Evergreen</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*tYrvxPfi0melmjyCsI5TxQ.png" /></figure><p><a href="https://evergreen.segment.com/">Evergreen</a> provides a <strong>Design System for the Web. </strong>It provided various pre-build components with great UI. It would be worth checking out.</p><h3>5. Webix</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxnkkpF3Qm-CAx1-Z9QzgQ.png" /></figure><p><a href="https://webix.com/">Webix</a> is yet another and very advance UI library that provides you UI for building complex and heavy web applications on a Large Scale.</p><ul><li><a href="https://medium.com/@gargpiyush195/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></li><li><a href="https://medium.com/@gargpiyush195/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a></li><li><a href="https://medium.com/@gargpiyush195/authentication-in-nodejs-using-json-web-tokens-jwt-936e6c0118ef">Authentication in Nodejs using JSON web tokens (JWT)</a></li></ul><h3>Social Links:</h3><p>Github: <a href="https://github.com/piyushgarg195">https://github.com/piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">https://www.linkedin.com/in/piyushgarg195/</a></p><p>Website: <a href="https://www.piyushgarg.dev/">https://www.piyushgarg.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42062f812c75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/top-5-libraries-for-reactjs-42062f812c75">Top 5 Libraries for Reactjs</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication in Nodejs using JSON web tokens (JWT)]]></title>
            <link>https://medium.com/daily-programmer/authentication-in-nodejs-using-json-web-tokens-jwt-936e6c0118ef?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/936e6c0118ef</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[jwt-token]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 16:38:15 GMT</pubDate>
            <atom:updated>2020-04-23T16:55:29.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*9pWUdYPAwCQoWdEnvZli4A.jpeg" /></figure><p>Hey there, In this article, we would be learning how to implement authentication in nodejs using express and <strong>JWT aka JSON web tokens</strong></p><h3>What are JSON web tokens?</h3><p>JSON web tokens or JWT is a simple long string that contains some data in an encoded way. Sounds confusing? here is an example</p><h4>A Sample JWT String may look like:</h4><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiUGl5dXNoIEdhcmciLCJlbWFpbCI6ImluZm9AcGl5dXNoZ2FyZy5kZXYiLCJpYXQiOjE1MTYyMzkwMjJ9.XaQC6iMAgESX8b-HT2AkclCAWDnAmNiHV7tq7b6GWRE</pre><h4>Now, Let’s decode the above JWT string</h4><blockquote>You can decode the string by visiting <a href="https://jwt.io/">https://jwt.io/</a> and paste the above string into the debugger present on the mentioned link.</blockquote><pre>{<br>  &quot;name&quot;: &quot;Piyush Garg&quot;,<br>  &quot;email&quot;: &quot;info@piyushgarg.dev&quot;,<br>  &quot;iat&quot;: 1516239022<br>}</pre><h4>So, I hope that now you have a simple idea that what JSON web tokens are!</h4><h3>Now, with that being set let&#39;s create an express application and implement authentication with JWT</h3><p>I&#39;ll be guiding you step by step and I would highly recommend you to code along with me.</p><h3>Step 0: Creating a boilerplate code.</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/615e51c53d0482c914de1e652a6aef95/href">https://medium.com/media/615e51c53d0482c914de1e652a6aef95/href</a></iframe><p>A very basic express starter code. We would be protecting the<strong> ‘/profile’</strong> route so that only logged in users can access that route.</p><h3>Step 1: Installing Dependencies</h3><p>For this project, we would be installing a few dependencies.</p><ol><li>Express</li><li>jsonwebtoken</li><li>cookie-parser</li></ol><h4>Run the following command in your terminal or command prompt:</h4><pre>npm install express jsonwebtoken cookie-parser</pre><h3>Step 2: Creating Middleware functions to deal with tokens</h3><p>In this step, we would be creating functions which would be used as middlewares to protect our certain routes.</p><h4>Trust me it&#39;s really simple 😉</h4><h3>Creating auth.js</h3><h4>So, Create a new .js file in your project directory. Lets call it as auth.js. In this file, we would be creating functions that we need to deal with tokens.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*4va-Bra1NEk_axInhvFTbA.png" /></figure><h4>Great going, Now let&#39;s create a couple of functions</h4><ol><li><strong>generateToken()</strong>: This function would take data as a parameter and return the token after generating it.</li><li><strong>isLoggedIn()</strong>: This function is responsible for checking if the current user is logged in or not.</li></ol><h4>Yeah! That&#39;s it. Lets Codeee 🤟🏻</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c6dbca71a4cbc00a2d0ffad37d392c4/href">https://medium.com/media/4c6dbca71a4cbc00a2d0ffad37d392c4/href</a></iframe><p>In auth.js we have created two functions as mentioned above. Please go through the code and you would understand the flow behind it.</p><h4>Yep, that&#39;s it. Now let&#39;s protect our routes</h4><p>Back to index.js let&#39;s create two routes <strong>signup route</strong> and<strong> login route</strong>.</p><p>In this article, I’ll be coding only the signup route.</p><p><strong>Your assignment is to create the login route.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d0f287923889e70d457f36ab80057d9/href">https://medium.com/media/9d0f287923889e70d457f36ab80057d9/href</a></iframe><h3>Step 3: let&#39;s protect our route</h3><p>To protect your route, just call the isLoggedIn function as middleware before the route that you want to protect and that&#39;s it.</p><p>Updated profile route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48b9cd3a4cee83953c543868f2918fab/href">https://medium.com/media/48b9cd3a4cee83953c543868f2918fab/href</a></iframe><p><strong>req.user</strong> holds the current user which is logged in. Navigate to auth.js line number 18:</p><pre>req.user = decoded;</pre><p>This is where we set the value of req.user to the current user.</p><blockquote>Value of req.user is exactly the same as we defined the payload while generating the token.</blockquote><h3>Finally: Let&#39;s test our implementation in postman</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1DZCgk8T7hP8H3PMFFBJxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iz-2DtkKdgCSjyOzmGdRdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cf9uNNdxU5kx9sPV3CmA8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50v90O8C8-Gwiq2-eh0pyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rorxp7ZrV5slK9ZZRU_iAQ.png" /></figure><h3>Congratulations! 😍 You have now learned how to do authentication in nodejs using JWT</h3><ul><li><a href="https://medium.com/@gargpiyush195/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a></li><li><a href="https://medium.com/@gargpiyush195/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></li><li><a href="https://medium.com/@gargpiyush195/how-to-create-a-vs-code-extension-c41314ef5a67">How to create a VS Code extension</a></li></ul><h4>Social Links:</h4><p>Github: <a href="https://github.com/piyushgarg195">https://github.com/piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">https://www.linkedin.com/in/piyushgarg195/</a></p><p>Website: <a href="https://www.piyushgarg.dev/">https://www.piyushgarg.dev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=936e6c0118ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/authentication-in-nodejs-using-json-web-tokens-jwt-936e6c0118ef">Authentication in Nodejs using JSON web tokens (JWT)</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create a VS Code extension]]></title>
            <link>https://medium.com/daily-programmer/how-to-create-a-vs-code-extension-c41314ef5a67?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c41314ef5a67</guid>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[vscode-extension]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 17:18:12 GMT</pubDate>
            <atom:updated>2020-04-22T18:19:38.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6BHcC_MSDqFze6v8MLECA.png" /></figure><p>Hi there, in this article we would be creating an extension for VS Code and publishing it to the vscode marketplace.</p><h3>Excited about that 🥰? Lets Start</h3><h3>What we are going to create?</h3><p>We would be building an auto-complete extension that auto-completes the bootstrap snippets in an Html file.</p><h4>Prerequisites</h4><p>You must have node.js installed on your machine.</p><h3>Step 1. Install Yo! 🤟🏻</h3><p>Yes, you read that correctly. We have to install yo to create our vscode extension.</p><p>To install yo fire-up your terminal or command prompt.</p><blockquote>Note: Windows users please open your command prompt as an administrator.</blockquote><p>After being set type in the following command:</p><h4>macOS:</h4><pre>sudo npm install -g yo</pre><h4>Windows:</h4><pre>npm install -g yo</pre><h3>Yo! you have successfully installed Yo 🎉</h3><h3>Step 2: Project setup</h3><p>Setting up the project is really simple.</p><p>All you need to do is:</p><ol><li>Create a new folder. Let us say “<strong>myFirstExtension</strong>”</li><li>Open your terminal or command prompt and navigate to the folder we have just created.</li><li>Run the following command</li></ol><pre>yo code</pre><h4>At this step, vscode extension generator would show up</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*EfICtDQhlciNFOmL2goyEw.png" /></figure><h4>From the given options choose New Code Snippets to create an auto-complete snippets extension.</h4><p>After that being done, you would be prompted with some questions such as the name of the extension, description etc.</p><h4>Also, there would be a prompt saying</h4><p>“<em>Enter the language for which the snippets should appear. The id is an identifier and is a single, lower-case name such as ‘PHP’, ‘javascript</em>”</p><p>Type in <strong>html</strong> for this as we are creating snippets for HTML</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RHneuU9UG-jhCmQDROf6pw.png" /></figure><h3>Hora 🎉 ! You have successfully set up the project and we are now ready to code our extension.</h3><h3>Step 3: Code the extension.</h3><p>Now you may close your terminals and command prompts and open the folder we created in the previous step. There you will notice a folder created with the name of your extension. Open this folder inside your favourite code editor. Like vscode in my case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*AQ5sbiriQrKRZSa8MHud7Q.png" /></figure><h4>Now, head over to snippets folder and open snippets.json file.</h4><p>At this point, your snippets.json file would we something like this</p><pre>{}</pre><p>Yep, it’s an empty object and we have to code our snippets inside this object.</p><h3>Lets Code!</h3><p>Code along with me:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90209417f513af877b18c0f954cfae28/href">https://medium.com/media/90209417f513af877b18c0f954cfae28/href</a></iframe><pre>prefix: what user would type to access the snippet</pre><pre>body: the body of the snippet. In this case Array of HTML tags</pre><h4>Yes that it! We have successfully created our first snippet.</h4><p>So whenever users types “!start” in vscode the body of our snippet would be printed there.</p><h4>You can Create multiple snippets by adding more objects to the main object</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3afb7410b586a8b8b13ca95fda2e51c/href">https://medium.com/media/d3afb7410b586a8b8b13ca95fda2e51c/href</a></iframe><h3>Wola! You have created your own very first extension 🥰</h3><p>Just keep adding your snippets and create some great snippets.</p><p><strong>Please post your extension links below because I cant wait to see what you have made.</strong></p><h4>Complete Bootstrap Snippets Code</h4><p><a href="https://gist.github.com/piyushgarg195/36fda82a1662e04618a34afbca293830">https://gist.github.com/piyushgarg195/36fda82a1662e04618a34afbca293830</a></p><h3>Step 4: Configuring the Extension</h3><p>At this point, you have successfully created your vscode extension.</p><p>Now open <strong>package.json</strong> file present in your project folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee30378ddba57d9cfc814d2ec99341a2/href">https://medium.com/media/ee30378ddba57d9cfc814d2ec99341a2/href</a></iframe><p>In this file, we need to make a few changes as listed below:</p><h4>1. Adding Publisher name in package.json</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55b63eda040f74f788d14942cc042f0b/href">https://medium.com/media/55b63eda040f74f788d14942cc042f0b/href</a></iframe><h3>2. Updating Readme.md file</h3><p>This file is the documentation of your extension. You need to edit this file before publishing your extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*wmljkVQ0YojWF1v9z1Y7cw.png" /></figure><h3>Finally: let&#39;s publish our extension</h3><p>To publish your extension first you need to download vse tool by writing a command</p><h4>macOS</h4><pre>sudo npm install -g vsce</pre><h4>Windows ( open command prompt as administrator)</h4><pre>npm install -g vsce</pre><h4>Now, after installing vse, navigate to your extension directory and open that directory in terminal or command prompt and type the following command</h4><pre>vsce package</pre><p>After this you would be prompted with a message saying</p><p><em>“A ‘repository’ field is missing from the ‘package.json’ manifest file.<br>Do you want to continue? [y/N]”</em></p><h4>Hit ‘y’ and press enter.</h4><p>This would create &lt;extension_name&gt;.vsix file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*qNITdWIu24-4hCIzeHX6JA.png" /></figure><h3>Congratulation! you are now ready to publish it.</h3><ul><li>Head over to <a href="https://marketplace.visualstudio.com/vscode"><strong>https://marketplace.visualstudio.com/vscode</strong></a><strong> </strong>and create your free account.</li><li>After signing select <strong>publish extensions </strong>from the top right corner.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZ6DtOuytMCV9I3W9B-WBA.png" /></figure><ul><li>Create a publisher</li></ul><blockquote><strong>Note: Please make sure that the publisher name in package.json is same as you create a publisher here.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*yookRKzRH2ecLnl546BGlA.png" /></figure><ul><li>Select <strong>+ Create new extension</strong> and select <strong>visual studio</strong> from the dropdown</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOQKREr8LzIC_OBWj-JLyQ.png" /></figure><ul><li>Upload your .vsix extension</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*HpqMHQqn28BHiqjRkWG1UA.png" /></figure><ul><li>Click Continue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*zwpzbiG5P6Uohn_ekQutKQ.png" /></figure><h3>Congrats! Your extension is now published! 😍</h3><h4>Do visit:</h4><p><a href="https://medium.com/@gargpiyush195/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c41314ef5a67" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/how-to-create-a-vs-code-extension-c41314ef5a67">How to create a VS Code extension</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building REST API with Node.js]]></title>
            <link>https://medium.com/daily-programmer/building-rest-api-with-node-js-4420ff6214b6?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4420ff6214b6</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 09:52:05 GMT</pubDate>
            <atom:updated>2020-04-22T13:02:45.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*0ObNJ2WuO599GlZaL4wBJQ.png" /></figure><p>A few years back, the only way to run a javascript code was in web browsers. But after the birth of Nodejs, we could run javascript code outside of the web browser.</p><p><strong>Node.js</strong> provides a run time environment to run javascript code. It is built on the <a href="https://v8.dev/">chrome’s open-source V8 engine.</a></p><p>After being said that let&#39;s build a real REST API in Node.js &amp; Express from scratch.</p><p>I&#39;ll be guiding you step by step with a detailed explanation from installing node to building our restful API.</p><h4>Now, What is an API? 🤷🏻‍♂️</h4><p>API stands for <strong>A</strong>pplication<strong> P</strong>rogramming <strong>I</strong>nterface. Yes I know it’s too much jargon.</p><h4><strong>In simple terms, API is a service that is used to deliver data and the content between the server and the client.</strong></h4><h3>So let’s build our very first API 😍</h3><h3>Step 1. Download and Install Node.js</h3><p>To download and install node js on your machine, head over to <a href="https://nodejs.org/en/">https://nodejs.org/en/</a> and select your download version.</p><p><strong>There are two types of download version:</strong></p><ol><li>LTS — Long Term Support</li><li>Current Version</li></ol><h4>In this tutorial, I would recommend you to download the LTS version as it’s more stable.</h4><h4>Download Link: <a href="https://nodejs.org/en/">https://nodejs.org/en/</a></h4><p>To Verify your installation open your terminal (macOS) or Command Prompt (Windows) and type <strong>“<em>node — version”. </em></strong>This will show your current installed version of nodejs on your machine.</p><h4>Congrats! you have successfully installed nodejs on your machine.</h4><h3>Step 2: Setting up the project folder</h3><p>After you have successfully installed node on your machine, lets set up our project structure for building API.</p><h4>Step 1: Create a new folder, let&#39;s name it as “myApi”</h4><h4>Step 2: Open terminal or command prompt and navigate to the recently created folder i.e “myApi”.</h4><h3>Step 3: Setting up package.json</h3><p>Every node project has a file named as package.json. This file contains some configs and names about your project. This file also keeps the track of the dependencies and packages used in our project.</p><p>To create a package.json, In your terminal or command prompt type</p><pre>npm init</pre><p>in your project folder and press enter. At this step, npm would ask you some questions like name, description, etc. Keep pressing enter key to accept all at default names.</p><h4>Now you have successfully created your own package.json file.</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d097ed7693e4b1318fd8d957d3de151/href">https://medium.com/media/1d097ed7693e4b1318fd8d957d3de151/href</a></iframe><blockquote>Please do verify that package.json is created inside the folder.</blockquote><h4>Create an index.js file</h4><blockquote>Note: If you had a look on to our <strong>package.json</strong> file, there is a key named as “main” and value is “index.js”, which means that index.js is the entry point of our application. So we need to create an <strong>index.js</strong> file in our<strong> project directory</strong>.</blockquote><p>Our Project Structure:</p><pre>myApi<br>|- index.js<br>|- package.json</pre><h4>Huraa! 🎉 our project is now set up and we can finally move on to code our API.</h4><h3>Step 4: Install dependencies</h3><p>Before we get started to code our API we need to install some dependencies in our project.</p><p>Installing dependencies is really simple. All you need to type is a command in your terminal or command prompt.</p><h4>For this project, we need a dependency i.e express.js</h4><p>Command:</p><pre>npm install express</pre><blockquote><a href="https://expressjs.com/">Express</a> is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.</blockquote><p>At this point a <strong>package.lock</strong> and <strong>node_modules</strong> folder would be created in your project directory. <strong>node_modules</strong> folder contains the source code of your all the dependencies that you install (express in our case).</p><h3>Step 5: Lets Code! 💻</h3><p>Open your index.js file and code along with me.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea00a7c3084e29ccb359c32adba9542d/href">https://medium.com/media/ea00a7c3084e29ccb359c32adba9542d/href</a></iframe><p>So firstly we will import express in our application using require() function and store it into a variable express.</p><pre>const express = require(&#39;express&#39;)</pre><p>Now, the express module that we have just imported returns a function which we can store into a different variable. By convention it is named as an app;</p><pre>const app = express()</pre><p>Great going! Now let&#39;s create a fake array of users which we would serve to our clients as an API.</p><pre>const userData = [</pre><pre>{</pre><pre>id: 1,</pre><pre>name: &#39;Jhon&#39;,</pre><pre>age: 20</pre><pre>},</pre><pre>{</pre><pre>id: 2,</pre><pre>name: &#39;Jane&#39;,</pre><pre>age: 23</pre><pre>},</pre><pre>{</pre><pre>id: 3,</pre><pre>name: &#39;Tim&#39;,</pre><pre>age: 34</pre><pre>},</pre><pre>];</pre><p>Feel free to add more users or data. 😉</p><h4>Now we are finally ready to create our API Endpoints</h4><p>An API endpoint is a URL where users can access to our API.</p><p>Creating Endpoints (also known as routes) is really simple.</p><p>Syntax: <strong>app.&lt;Request_Method&gt;(‘ Endpoint ’, callback function)</strong></p><p>Example: Suppose we want an endpoint named as posts that accept GET requests.</p><pre>app.get(&#39;/posts&#39;, function(req, res){<br>  // ... do stuff !<br>})</pre><p>The callback function has access to two parameters i.e <strong>Request</strong> and <strong>Response</strong> respectively.</p><p>So now you know how to create endpoints lets create some for our API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/843ae239a7febb83cd9ef01f25bf1da6/href">https://medium.com/media/843ae239a7febb83cd9ef01f25bf1da6/href</a></iframe><p>Now, please pay a little attention to endpoint 3.</p><pre>app.get(‘/api/user/:id’, function(req, res){<br>})</pre><p>Here “<strong>: id”</strong> at the end of the endpoint is a parameter.</p><p>Suppose user types <a href="http://www.example.com/api/user/1"><strong>www.example.com/api/user/1</strong></a><strong>, </strong>then the value of id would be equal to 1. you got the point!</p><p>We can access these parameters by typing req.params.id where req is the request which we received from the first parameter of the call back;</p><p>app.get(‘/example’, function(<strong>req</strong>, res){}) ;</p><h4>Sending Response</h4><p>To send a response to the client we use the res parameter.</p><pre>res.send(“Hey There”);</pre><p><strong>or JSON Response</strong></p><pre>res.json(object);</pre><p>In the end, we have to start our server by listening to some PORT and trust me this is also really simple.</p><p>Just use .listen function that accepts two parameters, PORT number and a callback function (which gets called when our server starts).</p><pre>app.listen(3000, function(){<br>   console.log(&#39;Server Started&#39;);<br>})</pre><p>In our example, we have used 3000 as our PORT number.</p><h3>Congratulations 🎉! Now let&#39;s start our application</h3><p>To start your server type</p><pre>node index.js </pre><p>in command prompt or terminal and your server would get started.</p><h3>Let&#39;s test our API</h3><p>Navigate to your favourite web browser and visit <strong>localhost:3000/api</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*J2ZzzlIzBRHbxziNUXO60w.png" /></figure><h4>Now let&#39;s test the users API endpoint.</h4><p>Visit: <strong>localhost:3000/api/users</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*hINtTBfEQtlKPDcOBF5v_g.png" /></figure><h4>Last but not the least, let&#39;s test our endpoint three</h4><p>Visit: <strong>localhost:3000/api/user/&lt;id&gt;</strong></p><blockquote>Example: l<strong>ocalhost:3000/api/user/2</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*qzeVUMFkA_7wRu72PQ8scg.png" /></figure><h3>Congrats! 😍 You have build your very own first API.</h3><p>Follow me on social media:</p><p>Github: <a href="https://github.com/piyushgarg195">piyushgarg195</a></p><p>Linkedin: <a href="https://www.linkedin.com/in/piyushgarg195/">Piyush Garg</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4420ff6214b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/building-rest-api-with-node-js-4420ff6214b6">Building REST API with Node.js</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 10 visual studio code extensions 2020]]></title>
            <link>https://medium.com/daily-programmer/top-10-visual-studio-code-extensions-2020-fc5761116443?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc5761116443</guid>
            <category><![CDATA[vscode-extension]]></category>
            <category><![CDATA[visual-studio-code]]></category>
            <category><![CDATA[vs-code-extensions]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Tue, 21 Apr 2020 16:23:49 GMT</pubDate>
            <atom:updated>2020-07-21T15:02:13.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HXuk-fDNE1uUmFgpjNxOxA.png" /></figure><p>Visual Studio Code (aka VS Code ) is “a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux” and here are some extensions that can make your vscode more powerful.</p><blockquote>Free ReactJs book <a href="https://amzn.to/2ZOfxJo">https://amzn.to/2ZOfxJo</a> ! Grab Now</blockquote><h3>1. Live Server</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*CfYU3dAoc-39eAJf2hgb3A.gif" /></figure><p>Linux sysadmins would often require to <a href="https://www.ubuntupit.com/best-linux-server-distro-top-10-compared-recommendation/">create a live server</a> in their <a href="https://www.ubuntupit.com/most-comprehensive-list-of-linux-monitoring-tools-for-sysadmin/">system for monitoring</a> several things in action. The Live Server extension can be used for setting up a local development server that will allow programmers to test out newly created static and dynamic pages effortlessly. The go-live button present in the taskbar will enable you to run your code as a development server directly, while you can also configure the extension to reload pages as soon as you save your current work.</p><p>Source: <a href="https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/">https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer">Live Server</a></h4><h3>2. Prettier</h3><p>Prettier is one of the best VS code extensions for modern-day web designers who need to follow a well-laid set of rules when designing their pages. It is a compelling extension which allows them to utilize the <a href="https://github.com/prettier/prettier">popular Prettier package</a>. It is a robust opinionated code formatter that allows designers to format their codes in a structured way. Prettier works together with JavaScript, TypeScript, HTML, CSS, Markdown, GraphQL, and other modern tools and allows the creation of cutting-edge apps effortlessly.</p><p>Source: <a href="https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/">https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode">Prettier</a></h4><h3><strong>3. Quokka</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*dkNlYDjAqjnHVrZSWqG1kA.gif" /></figure><p>Quokka.js is a robust, <a href="https://www.ubuntupit.com/best-javascript-editor-for-linux-best-20-javascript-ide-and-online-editors-reviewed/">modern-day scratchpad for JavaScript developers</a> who work on the VS Code for their projects extensively. It’s one of the most lightweight yet productive vscode extensions you can use to boost your workflow. Quokka checks your JavaScript code in real-time and provides instant feedback on which blocks have been already executed and which aren’t. If you’re looking for a JS extension to save your time spent behind code checks, Quokka is the solution for you.</p><p>Source: <a href="https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/">https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=WallabyJs.quokka-vscode">Quokka</a></h4><h3>4. Es Lint</h3><p>Integrates <a href="http://eslint.org/">ESLint</a> into VS Code. If you are new to ESLint check the <a href="http://eslint.org/">documentation</a>.</p><p>The extension uses the ESLint library installed in the opened workspace folder. If the folder doesn’t provide one the extension looks for a global install version. If you haven’t installed ESLint either locally or globally do so by running npm install eslint in the workspace folder for a local install or npm install -g eslint for a global install.</p><p>On new folders, you might also need to create a .eslintrc configuration file. You can do this by either using the VS Code command Create ESLint configuration or by running the eslint command in a terminal. If you have installed ESLint globally (see above) then run <a href="http://eslint.org/docs/user-guide/command-line-interface">eslint --init</a> in a terminal. If you have installed ESLint locally then run <a href="http://eslint.org/docs/user-guide/command-line-interface">.\node_modules\.bin\eslint --init</a> under Windows and <a href="http://eslint.org/docs/user-guide/command-line-interface">./node_modules/.bin/eslint --init</a> under Linux and Mac.</p><p>Source: <a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint">https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint">Es Lint</a></h4><h3>5. Git Lens</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*9R6g_gbXniassIthaLJjRA.png" /></figure><p>Git Lens is an awe-inspiring opensource extension for Visual Studio Code which will make contributing to third-party projects easier than ever. It allows users to take full control of the Git capabilities built into Code and aims to increase productivity to its peak. Thanks to features like Git blame annotations and code lens, understanding a new codebase will take the least amount of your valuable time.</p><p>Source: <a href="https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/">https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens">Git Lens</a></h4><h3>6. Bracket Pair Colorize</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*Mc7P11ekmFL7irjflGkMIg.png" /></figure><p>The Bracket Pair Colorizer extension is one of the most productive Visual Studio Code extensions for frequent programmers. If you are like me and often find yourself falsely navigating through those confusing curly brackets when inspecting branches of code; this one is a must-have for you. It allows the editor to identify matching brackets with colours you can define and configure. So, it enables you to know the depth of a code branch by merely having a look at the respective bracket’s colour.</p><p>Source: <a href="https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/">https://www.ubuntupit.com/best-visual-studio-code-extensions-for-programmers/</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer">Bracket Pair Colorize</a></h4><h3>7. Polacode</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*svapWsg8BDeRWMu7ExxS_A.gif" /></figure><p>Polacode is my favourite extensions that let you screenshot your code with very beautiful vscode theme. With polacode you can share your code over Instagram or any other social media platforms as an image</p><p><strong>Just hit: command + p and type “Polacode”</strong></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=pnp.polacode">Polacode</a></h4><h3>8. Better Comments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*mfnQ2TrE1TqSA_zB4GXzsA.png" /></figure><p>The Better Comments extension will help you create more human-friendly comments in your code.<br>With this extension, you will be able to categorise your annotations into:</p><ul><li>Alerts</li><li>Queries</li><li>TODOs</li><li>Highlights</li><li>Commented out code can also be styled to make it clear the code shouldn’t be there</li><li>Any other comment styles you’d like can be specified in the settings</li></ul><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=aaron-bond.better-comments"><strong>Better Comments</strong></a></h4><h3>9. REST Client</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJhaYRMauyvxLw4xsrQvYA.png" /></figure><p>REST Client allows you to send HTTP request and view the response in Visual Studio Code directly.</p><p><strong>Usage: Open a blank file and type:</strong></p><pre>GET https://jsonplaceholder.typicode.com/todos/1</pre><p><strong>and press CMD + option + R ( MacOs ) or Ctrl + Alt + R (Windows )</strong></p><h4><strong>Download: </strong><a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client"><strong>REST Client</strong></a></h4><h3>10. Markdown all in one</h3><p>All you need to write Markdown (keyboard shortcuts, table of contents, auto preview and more)</p><p>Source: <a href="https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one">https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one</a></p><h4>Download: <a href="https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one">Markdown All in one</a></h4><h4>Must have a laptop for programmers <a href="https://amzn.to/3jo6s1D">https://amzn.to/2ZOfxJo</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc5761116443" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/top-10-visual-studio-code-extensions-2020-fc5761116443">Top 10 visual studio code extensions 2020</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement React Routing]]></title>
            <link>https://medium.com/daily-programmer/react-routing-6be92384685f?source=rss-ca8430bd188a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6be92384685f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-routing]]></category>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-router-dom]]></category>
            <dc:creator><![CDATA[Piyush Garg]]></dc:creator>
            <pubDate>Tue, 21 Apr 2020 15:23:33 GMT</pubDate>
            <atom:updated>2020-04-21T18:30:16.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYpbVkUH_3Kh2Yk1MoDl1g.png" /></figure><p>In this article, I will be explaining how to implement routing in react app in very simple steps.</p><h3>Step 1: Install react-router-dom</h3><p><a href="https://www.npmjs.com/package/react-router-dom">react-router-dom</a></p><pre>npm install react-router-dom</pre><h3>Step 2: Importing react-router-dom in our project</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a6fac1ad47c01d2a72a2c4093a88587/href">https://medium.com/media/6a6fac1ad47c01d2a72a2c4093a88587/href</a></iframe><p>In the above code, we have wrapped our <strong>&lt;App/&gt;</strong> component with <strong>&lt;BrowserRouter /&gt;</strong> which enables us to use Html 5 history API.</p><h3>Step 3: Implement Routing</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5df27e30478e9c5e6a243ef804e7a1a8/href">https://medium.com/media/5df27e30478e9c5e6a243ef804e7a1a8/href</a></iframe><p>In app.js we need to implement switch cases with various routes as shown in the above code.</p><p>Each Route component needs two mandatory props and that is the path and the component to render.</p><p>Congratulations, you have now implemented routing in your react app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6be92384685f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/daily-programmer/react-routing-6be92384685f">How to implement React Routing</a> was originally published in <a href="https://medium.com/daily-programmer">Daily Programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>