<?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: Vikas Raj</title>
    <description>The latest articles on DEV Community by Vikas Raj (@numtostr).</description>
    <link>https://dev.to/numtostr</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%2F119138%2F44ec9c5b-c40e-43eb-b8a3-d6e52654546f.png</url>
      <title>DEV Community: Vikas Raj</title>
      <link>https://dev.to/numtostr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/numtostr"/>
    <language>en</language>
    <item>
      <title>Testing Node.js. How?</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Wed, 31 Jul 2019 04:25:55 +0000</pubDate>
      <link>https://dev.to/numtostr/testing-node-js-how-ieb</link>
      <guid>https://dev.to/numtostr/testing-node-js-how-ieb</guid>
      <description>&lt;p&gt;TBH I don't like writing test. But as the project grows changing one line of code can break your app if you don't know which part your app was dependent on that deleted line.&lt;/p&gt;

&lt;p&gt;Different devs choose different tools for testing, which is sometime confusing.&lt;/p&gt;

&lt;p&gt;So, what you choose for testing your Node.js apps?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>node</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
    <item>
      <title>ECMASCRIPT: Optional Chaining | Stage 3</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Fri, 26 Jul 2019 04:06:54 +0000</pubDate>
      <link>https://dev.to/numtostr/ecmascript-optional-chaining-stage-3-2j5e</link>
      <guid>https://dev.to/numtostr/ecmascript-optional-chaining-stage-3-2j5e</guid>
      <description>&lt;p&gt;Optional chaining is at stage 3 🎉🎉. This one is my favourite. Soon will be available in TypeScript.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/tc39" rel="noopener noreferrer"&gt;
        tc39
      &lt;/a&gt; / &lt;a href="https://github.com/tc39/proposal-optional-chaining" rel="noopener noreferrer"&gt;
        proposal-optional-chaining
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Optional Chaining for JavaScript&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Status&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://github.com/tc39/proposals" rel="noopener noreferrer"&gt;ECMAScript proposal&lt;/a&gt; at stage 4 of the process.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Authors&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Claude Pache (&lt;a href="https://github.com/claudepache" rel="noopener noreferrer"&gt;github&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Gabriel Isenberg (&lt;a href="https://github.com/gisenberg" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/the_gisenberg" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Daniel Rosenwasser (&lt;a href="https://github.com/DanielRosenwasser" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/drosenwasser" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Dustin Savery (&lt;a href="https://github.com/dusave" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/dustinsavery" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview and motivation&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;When looking for a property value that's deep in a tree-like structure, one often has to check whether intermediate nodes exist:&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;var&lt;/span&gt; &lt;span class="pl-s1"&gt;street&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;user&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;address&lt;/span&gt; &lt;span class="pl-c1"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="pl-s1"&gt;user&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;address&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;street&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Also, many API return either an object or null/undefined, and one may want to extract a property from the result only when it is not null:&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;var&lt;/span&gt; &lt;span class="pl-s1"&gt;fooInput&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;myForm&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;querySelector&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;'input[name=foo]'&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;
&lt;span class="pl-k"&gt;var&lt;/span&gt; &lt;span class="pl-s1"&gt;fooValue&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;fooInput&lt;/span&gt; ? &lt;span class="pl-s1"&gt;fooInput&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;value&lt;/span&gt; : &lt;span class="pl-c1"&gt;undefined&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;The Optional Chaining Operator allows a developer to handle many of those cases without repeating themselves and/or assigning intermediate results in temporary variables:&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;var&lt;/span&gt; &lt;span class="pl-s1"&gt;street&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;user&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/tc39/proposal-optional-chaining" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>ecmascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>ECMASCRIPT: Nullish Coalescing</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Wed, 24 Jul 2019 04:21:12 +0000</pubDate>
      <link>https://dev.to/numtostr/ecmascript-nullish-coalescing-4mdl</link>
      <guid>https://dev.to/numtostr/ecmascript-nullish-coalescing-4mdl</guid>
      <description>&lt;p&gt;&lt;strong&gt;Nullish Coalescing is at Stage 3&lt;/strong&gt;. This one is interesting.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/tc39" rel="noopener noreferrer"&gt;
        tc39
      &lt;/a&gt; / &lt;a href="https://github.com/tc39/proposal-nullish-coalescing" rel="noopener noreferrer"&gt;
        proposal-nullish-coalescing
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Nullish coalescing proposal x ?? y
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Nullish Coalescing for JavaScript&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Status&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Current Stage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stage 4&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Authors&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Gabriel Isenberg (&lt;a href="https://github.com/gisenberg" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/the_gisenberg" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Daniel Ehrenberg (&lt;a href="https://github.com/littledan" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/littledan" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Daniel Rosenwasser (&lt;a href="https://github.com/DanielRosenwasser" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/drosenwasser" rel="nofollow noopener noreferrer"&gt;twitter&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview and motivation&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;When performing property accesses, it is often desired to provide a default value if the result of that property access is &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt;. At present, a typical way to express this intent in JavaScript is by using the &lt;code&gt;||&lt;/code&gt; operator.&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;response&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-c1"&gt;settings&lt;/span&gt;: &lt;span class="pl-kos"&gt;{&lt;/span&gt;
    &lt;span class="pl-c1"&gt;nullValue&lt;/span&gt;: &lt;span class="pl-c1"&gt;null&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;height&lt;/span&gt;: &lt;span class="pl-c1"&gt;400&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;animationDuration&lt;/span&gt;: &lt;span class="pl-c1"&gt;0&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;headerText&lt;/span&gt;: &lt;span class="pl-s"&gt;''&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt;
    &lt;span class="pl-c1"&gt;showSplashScreen&lt;/span&gt;: &lt;span class="pl-c1"&gt;false&lt;/span&gt;
  &lt;span class="pl-kos"&gt;}&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;undefinedValue&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;response&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;settings&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;undefinedValue&lt;/span&gt; &lt;span class="pl-c1"&gt;||&lt;/span&gt; &lt;span class="pl-s"&gt;'some other default'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt; &lt;span class="pl-c"&gt;// result: 'some other default'&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;nullValue&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;response&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;settings&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;nullValue&lt;/span&gt; &lt;span class="pl-c1"&gt;||&lt;/span&gt; &lt;span class="pl-s"&gt;'some other default'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt; &lt;span class="pl-c"&gt;// result: 'some other default'&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This works well for the common case of &lt;code&gt;null&lt;/code&gt;…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/tc39/proposal-nullish-coalescing" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Running React and Node.js in one shot with Docker!</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Tue, 23 Jul 2019 11:50:02 +0000</pubDate>
      <link>https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-docker-3o09</link>
      <guid>https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-docker-3o09</guid>
      <description>&lt;p&gt;This is the second part of my previous post. If you haven't read my first post, please check it out as it serves as a base for this part.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-concurrently-2oac"&gt;Connecting &amp;amp; Running with Concurrently&lt;/a&gt; (first post)&lt;/li&gt;
&lt;li&gt;  Using Docker (this post)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  TL;DR | If you don't know docker you can just turn back. But, If you still want to read go ahead.
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this post we'll be looking at the docker way of running React and Node.js. This is a kind of advance development setup and I hope you already &lt;a href="https://docs.docker.com/install/"&gt;installed&lt;/a&gt; and know the basics of &lt;a href="https://docs.docker.com/engine/docker-overview/"&gt;docker&lt;/a&gt; and &lt;a href="https://docs.docker.com/compose/"&gt;docker-compose&lt;/a&gt;. If you want to know more about docker head over to &lt;a href="https://docker.com"&gt;docker.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  # Initial setup
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;awesome_project
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this approach we'll not polluting the root folder. Client and Server will stay on their dedicated folder. In this way we can separate client and server at any time if we have to, without breaking anything. To make it work properly, each of them should have a &lt;a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/"&gt;Dockerfile&lt;/a&gt; and all will be connected with the docker-compose.&lt;/p&gt;

&lt;h2&gt;
  
  
  # Client Setup (React)
&lt;/h2&gt;

&lt;h4&gt;
  
  
  ~ Create react app
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;awesome_project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npx create-react-app client
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will create a folder named &lt;em&gt;client&lt;/em&gt; which holds our react app.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Dockerfile for React
&lt;/h4&gt;

&lt;p&gt;Create a file name &lt;code&gt;Dockerfile&lt;/code&gt; in the &lt;strong&gt;&lt;em&gt;client&lt;/em&gt;&lt;/strong&gt; folder and paste the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; node:lts-slim&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /usr/src/app

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /usr/src/app&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 3000&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; [ "npm", "start" ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will be our docker image instructions for our react app where our react app will get compiled and run.&lt;/p&gt;

&lt;h2&gt;
  
  
  # Server Setup (Node.js)
&lt;/h2&gt;

&lt;p&gt;Our server code will stay in a folder named &lt;code&gt;server&lt;/code&gt; in the root folder. Here you can use express or any other framework of your choice to make up the server. Or you can use &lt;a href="https://gist.github.com/vkasraj/d0de199f77834f86c5971c81716ac70b"&gt;this sample&lt;/a&gt; to quickly setup a server.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Dockerfile for Node Server
&lt;/h4&gt;

&lt;p&gt;Create a &lt;code&gt;Dockerfile&lt;/code&gt; in the &lt;strong&gt;&lt;em&gt;server&lt;/em&gt;&lt;/strong&gt; folder. And make sure you have a &lt;code&gt;dev&lt;/code&gt; script in you &lt;code&gt;package.json&lt;/code&gt;. If you have different script for running your server, you can change the &lt;code&gt;CMD&lt;/code&gt; instruction in the &lt;code&gt;Dockerfile&lt;/code&gt; below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; node:lts-slim&lt;/span&gt;

&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /usr/src/app

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /usr/src/app&lt;/span&gt;

&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 5000&lt;/span&gt;

&lt;span class="c"&gt;# You can change this&lt;/span&gt;
&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; [ "npm", "run", "dev" ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  # Running with docker-compose
&lt;/h2&gt;

&lt;p&gt;Docker-compose helps us to combine and run mutiple Dockerfile into a single network container. Make a file named &lt;code&gt;docker-compose.yml&lt;/code&gt; in the &lt;strong&gt;&lt;em&gt;root&lt;/em&gt;&lt;/strong&gt; of the project and copy the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3"&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;frontend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;awesome_web&lt;/span&gt;
        &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./client&lt;/span&gt;
            &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vikasraj/awesome_web&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3000:3000"&lt;/span&gt;
        &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./client:/usr/src/app&lt;/span&gt;
    &lt;span class="na"&gt;backend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;container_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;awesome_server&lt;/span&gt;
        &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./server&lt;/span&gt;
            &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;vikasraj/awesome_server&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5000:5000"&lt;/span&gt;
        &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./server:/usr/src/app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally, we'll have a folder structure somewhat like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; awesome_project
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; client &lt;span class="c"&gt;# This is our react front-end&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; node_modules
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; src
        - Dockerfile
        - package.json
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; server &lt;span class="c"&gt;# This is our Node.js server&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; node_modules
        - index.js
        - Dockerfile
        - package.json
    - docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Lastly, you need to change the &lt;code&gt;proxy&lt;/code&gt; field in the &lt;code&gt;client/package.json&lt;/code&gt; like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
     &lt;/span&gt;&lt;span class="nl"&gt;"proxy"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://backend:5000"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;backend&lt;/code&gt; is the name of our backend service in the compose file&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we can run our project by running following command. This will create docker images and &lt;a href="https://docs.docker.com/storage/volumes/"&gt;volumes&lt;/a&gt; which will run in the containers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker-compose up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to build your images before starting your containers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker-compose up &lt;span class="nt"&gt;--build&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This can be a tedious approach to work with as you must have the knowledge of docker and docker-compose. But It has some advantage:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  One setup for all development workflow.&lt;/li&gt;
&lt;li&gt;  Docker can be used for any programming language.&lt;/li&gt;
&lt;li&gt;  Production Deloyment can be a breeze, if you use docker in your DevOps.&lt;/li&gt;
&lt;li&gt;  No npm package required (though replaced by docker).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>node</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Running React and Node.js in one shot with concurrently!</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Mon, 22 Jul 2019 14:10:38 +0000</pubDate>
      <link>https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-concurrently-2oac</link>
      <guid>https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-concurrently-2oac</guid>
      <description>&lt;p&gt;Often time working on a full stack project can be intimidating. I often found myself in the same situation whether it is a personal or proffesional project. When I started to work with React and Node.js, the first question that just came up was, How do I even &lt;strong&gt;connect&lt;/strong&gt; and &lt;strong&gt;run&lt;/strong&gt; these two together?&lt;/p&gt;

&lt;p&gt;This will be two part series where we look at different approaches to run React and Node.js in development environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Connecting &amp;amp; Running with Concurrently (this post)&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-docker-3o09"&gt;Using Docker&lt;/a&gt; (second post)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connecting React to Node.js (also works for any backend) is fairly easy and commonly known as React Proxy. You just need to add &lt;code&gt;proxy&lt;/code&gt; field in your &lt;code&gt;package.json&lt;/code&gt; of your React project and point it to your development backend server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"proxy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:5000"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to learn to more just &lt;a href="https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development"&gt;click here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Running React and Node.js is more complicated than connecting. This will be two part series where we look at different approaches to run both of them in parallel. Both approches are different in many ways i.e. tools used, folder structure.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Using concurrently
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/concurrently"&gt;Concurrently&lt;/a&gt; is a package which can run multiple npm scripts simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Initial setup
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;awesome_project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;awesome_project &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will create a &lt;code&gt;package.json&lt;/code&gt; in our project with some default options.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Creating react app
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npx create-react-app client
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will create a folder named &lt;em&gt;client&lt;/em&gt; which holds our react app.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Some Node.js code
&lt;/h4&gt;

&lt;p&gt;Create &lt;code&gt;index.js&lt;/code&gt; in root of your project and paste the following code if you don't have server setup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cp"&gt;#!/usr/bin/env node
&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Port Environment variable&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Creating the node server&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SERVER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Firing up the server on selected port&lt;/span&gt;
&lt;span class="nx"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;listening&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;[Server]::LISTEN:%s&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Callback function for checking connecting or error&lt;/span&gt;
&lt;span class="nx"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`[Server]::ERROR:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  ~ Installing concurrently
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; concurrently
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To make concurrently work with React and Node, we have to add some script in &lt;code&gt;package.json&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"server"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"client"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm start --prefix client"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"concurrently &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;npm run server&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;npm run client&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally, we'll have a folder structure somewhat like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; awesome_project
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; node_modules
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; client &lt;span class="c"&gt;# This is our react front-end and else will be our node.js backend&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; node_modules
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; src
        - package.json
    - index.js
    - package.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;dev&lt;/code&gt; script will run both React and Node.js app in our project and the proxy will connect both of them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Using concurrently is perfectly fine for most of the developer (this is also the same approach which I used initially). But It has one problem that I find annoying which is &lt;strong&gt;folder structure&lt;/strong&gt; (might be different for you).&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/numtostr/running-react-and-node-js-in-one-shot-with-docker-3o09"&gt;second post&lt;/a&gt; we'll be looking at the docker way. So, If you don't know docker just stay here.&lt;/p&gt;

</description>
      <category>node</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Best way to write class methods in javascript?</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Fri, 19 Jul 2019 14:45:42 +0000</pubDate>
      <link>https://dev.to/numtostr/best-wayto-write-class-methods-in-javascript-1ml3</link>
      <guid>https://dev.to/numtostr/best-wayto-write-class-methods-in-javascript-1ml3</guid>
      <description>&lt;p&gt;Can anyone tell which is the beat approach to write class methods in js and What are the pros and cons?&lt;/p&gt;

&lt;h1&gt;
  
  
  First Approach
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Second Approach
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Dog&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;Dog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bark&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bark&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Environment variables in Node.js. The Right way!</title>
      <dc:creator>Vikas Raj</dc:creator>
      <pubDate>Sat, 13 Jul 2019 04:39:11 +0000</pubDate>
      <link>https://dev.to/numtostr/environment-variables-in-node-js-the-right-way-15ad</link>
      <guid>https://dev.to/numtostr/environment-variables-in-node-js-the-right-way-15ad</guid>
      <description>&lt;p&gt;This is my first blog post. Hope y'all like it 🤞.&lt;/p&gt;

&lt;p&gt;Environment variables are very fundamental part of developing with Node.js or any server side language. They always contains very sensitive data and doesn't meant to be shared with outside world. You have to make sure that your server is properly configured to make use of correct variables for both development and production environments. Any mistake can lead your server to crash.&lt;/p&gt;

&lt;p&gt;Working with environment variable in Node.js is very easy and simple. This post will walk you through the different approaches of using environment variables in Node.js.&lt;/p&gt;

&lt;p&gt;If you want to learn about environment variables in Node.js in click &lt;a href="https://nodejs.org/docs/latest/api/process.html#process_process_env"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Using package.json
&lt;/h2&gt;

&lt;p&gt;You are thinking how? But you can pass &lt;code&gt;key=value&lt;/code&gt; pairs directly in the npm scripts in the &lt;em&gt;package.json&lt;/em&gt;. This is a valid a place to put environment variable but &lt;em&gt;&lt;strong&gt;not a secure&lt;/strong&gt;&lt;/em&gt; place.&lt;/p&gt;

&lt;p&gt;Below is an example of setting Node.js execution environment to production on the npm's start script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; This will probably won't work with Windows OS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"NODE_ENV=production node bin/www.js"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also use this approach when I work with &lt;a href="https://github.com/visionmedia/debug"&gt;debug&lt;/a&gt; module or setting the Node.js execution environemnt. Some points to be considered when using this approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Shouldn't not put any sensitive data in here as it is visible to everyone and you can't ignore &lt;em&gt;package.json&lt;/em&gt; in the &lt;em&gt;.gitignore&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;  Don't put more than 2 variables as it could quickly becomes a mess.&lt;/li&gt;
&lt;li&gt;  Separating variables for development and production environment can be very hard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Different keys files
&lt;/h2&gt;

&lt;p&gt;This approach is completely different from first approach and addresses some of the issue of first approach.&lt;/p&gt;

&lt;p&gt;Instead of using &lt;em&gt;package.json&lt;/em&gt;, we can use &lt;strong&gt;keys.dev.js&lt;/strong&gt; for development and &lt;strong&gt;keys.prod.js&lt;/strong&gt; for production environment. Each file stores different variables for different environment.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;Make sure to ignore keys.dev.js in the .gitignore before commiting any changes.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;But how we can use them?&lt;/p&gt;

&lt;p&gt;Using them can be tricky (when i initially got frustrated), So pay attention. Both files are exported by a third file i.e &lt;strong&gt;keys.js&lt;/strong&gt; which checks the Node.js execution environement i.e. &lt;code&gt;NODE_ENV&lt;/code&gt; and exports the correct keys file.&lt;/p&gt;

&lt;p&gt;But how can I check Node.js environment before running our code? Look at the first approch for a brief. Below is an example for this approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// keys.dev.js ==========&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// keys.prod.js ==========&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// keys.js ==========&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;devKeys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;keys.dev.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;prodKeys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;keys.prod.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;prodKeys&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;devKeys&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach addresses all the issues of the first approach.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Multiple variables can be easily managed.&lt;/li&gt;
&lt;li&gt;  Development and production both have their own keys.&lt;/li&gt;
&lt;li&gt;  Development keys i.e. &lt;strong&gt;keys.dev.js&lt;/strong&gt; can be ignored in the &lt;em&gt;.gitignore&lt;/em&gt; keeping secrets away from others.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But no one wants to maintain extra code/file (including me). There must be a better way to do this!&lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;code&gt;.env&lt;/code&gt; comes to the rescue
&lt;/h2&gt;

&lt;p&gt;.env is a special file which is used to define environment variables in Node.js. It holds &lt;code&gt;key=value&lt;/code&gt; pairs to define the variables.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;Make sure to ignore .env in the .gitignore before commiting any changes.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;But, Node.js doesn't know how to read and parse this file. How do we do that? Either you could write your own logic to read and parse the file or Use a third party module to do the heavy lifting.&lt;/p&gt;

&lt;p&gt;One popular module is &lt;a href="https://github.com/motdotla/dotenv"&gt;dotenv&lt;/a&gt; (which i use) which can guide through the basic of .env file.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Creating the file
&lt;/h4&gt;

&lt;p&gt;First create a file with name .env in the &lt;em&gt;root of the project&lt;/em&gt; which contains all variable which will be injected in the environment by the dotenv.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env ======&lt;/span&gt;
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;5000
&lt;span class="nv"&gt;WHO_AM_I&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Who Knows"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  ~ Configuring the dotenv
&lt;/h4&gt;

&lt;p&gt;First intall the dotenv package from the npm as a dev dependencies as we don't need this in production.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-D&lt;/span&gt; dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are several methods to load dotenv package. But, I will show you the method that i like.&lt;/p&gt;

&lt;p&gt;To load the dotenv package and correctly read the .env file you have to modify the scripts in the package.json. Like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node bin/www.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node -r dotenv/config bin/www.js"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;For&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;nodemon&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;users&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;====&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodemon -r dotenv/config bin/www.js"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see there are two scripts&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;start&lt;/strong&gt; for the production&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;dev&lt;/strong&gt; for the development which loads the dotenv module&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will make sure that we don't accidentally load the dotenv in production.&lt;/p&gt;

&lt;h4&gt;
  
  
  ~ Run the code
&lt;/h4&gt;

&lt;p&gt;Now you can run the server but typing the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And BOOM! You can now use all the variables defined in the .env file by the following syntax.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;YOUR_VARIABLE_NAME&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So What kind of magic is this? What is going on? In the dev script we are telling node to preload a module by passing &lt;code&gt;-r &amp;lt;module_name&amp;gt;&lt;/code&gt; flag. By requiring dotenv/config which read and parse the .env and sets the variable in the environment and provide access to those variable before running our code.&lt;/p&gt;

&lt;p&gt;Now, we have a single place to define all the environment variables.&lt;/p&gt;

&lt;p&gt;To make life a little easier, you can make a separate file i.e &lt;strong&gt;keys.js&lt;/strong&gt; which exports all those variable like so we do in the second approach. This helps us to organize all the variables we use in our code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; If you add variables in the .env then also update your exports in &lt;strong&gt;keys.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// keys.js ======&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;WHO_AM_I&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WHO_AM_I&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  Points to be considered
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Always ignore your development keys in the &lt;em&gt;.gitignore&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;  Don't mess with &lt;code&gt;NODE_ENV&lt;/code&gt; variable. Values other than &lt;strong&gt;development&lt;/strong&gt; or &lt;strong&gt;production&lt;/strong&gt; can break your app.&lt;/li&gt;
&lt;li&gt;  Always restart your app after changing environment variables.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>javascript</category>
      <category>security</category>
    </item>
  </channel>
</rss>
