<?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 Ashton Fernandes on Medium]]></title>
        <description><![CDATA[Stories by Ashton Fernandes on Medium]]></description>
        <link>https://medium.com/@ashton.s.fernandes?source=rss-eecbc557431e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fWaPsF-o-TVyxHb6qoBI7Q.png</url>
            <title>Stories by Ashton Fernandes on Medium</title>
            <link>https://medium.com/@ashton.s.fernandes?source=rss-eecbc557431e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:06:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashton.s.fernandes/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[Getting started with Web Development — Part 2: CSS]]></title>
            <link>https://medium.com/@ashton.s.fernandes/getting-started-with-web-development-part-2-css-65e689869af1?source=rss-eecbc557431e------2</link>
            <guid isPermaLink="false">https://medium.com/p/65e689869af1</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[website-development]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ashton Fernandes]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 03:17:11 GMT</pubDate>
            <atom:updated>2024-02-02T03:17:11.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting started with Web Development — Part 2: CSS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpv9VruBXSVd939Pv6bArg.jpeg" /></figure><p>Welcome to Part 2 of the Getting started with Web Development series. In this part, we will focus on CSS!</p><h3>What is CSS?</h3><p>Cascading Style Sheets (CSS) is a very integral part of Web Development. This is what is used to enhance the look and experience of your web page. This is what users look at and it helps define part of the user experience.</p><h3>Tools required</h3><ul><li><strong>Computer</strong></li><li><strong>Text Editor of choice (</strong>I love MS VS Code!)</li><li><strong>Browser</strong> (I always use Chrome)</li><li><strong>Browser Developer tools</strong> (In my case — Chrome Developer Tools)</li></ul><h3>Source code</h3><p>You can get the source code for the app <a href="https://github.com/ashtonfernandes/mern-stack">here</a>.</p><blockquote>Let’s get started!</blockquote><h3>Part 1: Styling a web page</h3><p>There are mainly three different ways of styling a web page:</p><ul><li><strong>In-line CSS</strong></li></ul><p>An example:</p><pre>&lt;h1 style=&quot;color:blue;&quot;&gt;Hello&lt;/h1&gt;</pre><ul><li><strong>CSS in the header</strong></li></ul><p>An example:</p><pre>&lt;h1 style=&quot;color:blue;&quot;&gt;Hello&lt;/h1&gt;</pre><ul><li><strong>External CSS</strong></li></ul><p>An example:</p><pre>&lt;h1 style=&quot;color:blue;&quot;&gt;Hello&lt;/h1&gt;</pre><p>Out of the three options, linking an external CSS file is the best option (my opinion) as it keeps the CSS separate from the HTML and JavaScript, which makes the code easier to read and maintain.</p><h3>Part 2: CSS selectors</h3><p>CSS selectors are used to select various HTML elements and add styling to them. There are different selectors we can use to add a style. Some of the most widely used ones are:</p><p><strong>Class Selectors</strong>:</p><p>An example:</p><pre>.classname {<br>     color: &quot;green&quot;<br>}</pre><p>This selector is used to add style to elements with a distinct name. Please note, you have to use a (.) before the classname to add the style.</p><p><strong>ID Selectors</strong>:</p><p>An example:</p><pre>#id {<br>     color: &quot;green&quot;<br>}</pre><p>This selector is used to add style to elements with a distinct id. Please note, you have to use a (#) before the id to add the style.</p><p><strong>Multiple Class Selectors</strong>:</p><p>An example:</p><pre>.classname1 .classname2 {<br>     color: &quot;green&quot;<br>}</pre><p>This selector is used to add style to multiple classnames. This is used when two classes have some commons styles. Please note, you have to use a (.) before the classname and then a space followed by a (.) before the second classname to add the style.</p><p><strong>Element Selectors</strong>:</p><p>An example:</p><pre>p {<br>     color: &quot;green&quot;<br>}</pre><p>This selector is used to add style certain elements. Please note, you have to just use the element name to add the style.</p><p>There are many more CSS selectors but the examples provided above should help you get started with the basics.</p><h3>Part 3: Flexbox</h3><p>The Flexbox layout, is a one-dimensional layout system. It is primarily used to create flexible and responsive layouts for web page components. A flexbox layout is made up of a parent element / container that will hold all of the various child elements.</p><p>An example:</p><p>HTML:</p><pre>&lt;div class=&quot;parent-class&quot;&gt;<br> &lt;div class=&quot;child-class&quot;&gt;1&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;2&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;3&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;4&lt;/div&gt;<br>&lt;/div&gt;</pre><p>CSS:</p><pre>.parent-class {<br>  display: flex;<br>}</pre><p>With flex display, it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*yFaRzIwTeiFlCjIEMOx1cA.png" /></figure><h3>Part 4: Grid</h3><p>The Grid layout is a two-dimensional layout system. It is primarily used to create more complex layouts with rows and columns. Similarly to the Flexbox layout, thegrid layout is made up of a parent element / container that will hold all of the various child elements.</p><p>An example:</p><p>HTML:</p><pre>&lt;div class=&quot;parent-class&quot;&gt;<br> &lt;div class=&quot;child-class&quot;&gt;1&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;2&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;3&lt;/div&gt;<br> &lt;div class=&quot;child-class&quot;&gt;4&lt;/div&gt;<br>&lt;/div&gt;</pre><p>CSS:</p><pre>.parent-class {<br>  display: grid;<br>}</pre><p>With grid display, it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*2apzk2TK_PELQItfQ1xRyQ.png" /></figure><blockquote>Awesome, you now have the knowledge required to enhance the look of your web pages!</blockquote><h3>Part 5: References</h3><p><a href="https://www.w3schools.com/css/">https://www.w3schools.com/css/</a></p><p><a href="https://www.w3schools.com/css/css3_flexbox.asp">https://www.w3schools.com/css/css3_flexbox.asp</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox">https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox</a></p><p><a href="https://www.w3schools.com/css/css_grid.asp">https://www.w3schools.com/css/css_grid.asp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65e689869af1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting started with Web Development — Part 1: HTML]]></title>
            <link>https://medium.com/@ashton.s.fernandes/getting-started-with-web-development-part-1-html-71a52e9a53c5?source=rss-eecbc557431e------2</link>
            <guid isPermaLink="false">https://medium.com/p/71a52e9a53c5</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[html5]]></category>
            <dc:creator><![CDATA[Ashton Fernandes]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 00:16:54 GMT</pubDate>
            <atom:updated>2023-09-27T00:16:54.155Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting started with Web Development — Part 1: HTML</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ck28qieRJXy0C3czoJBvoQ.jpeg" /></figure><p><strong>Web Development</strong> is a beautiful journey to embark on. I started on this journey years ago and slowly made a transition to Architecture. I currently work as a Solution Architect in Consulting and work with clients in various industries including Financial Services, Public Sector, Travel and Transportation, Energy, Utilities, etc. Over the years, many people have approached me to learn more about Web Development and I finally decided to write about it.</p><p>To better understand Web Development, we can break it down into three categories:</p><h3><strong>1. Structure</strong></h3><p>This is the part that is comprised of HTML.</p><p>What is HTML?</p><p>Hypertext Markup Language (HTML) is the markup language used for documents designed to be displayed in a web browser.</p><p>This is what we will used to create the different elements in a web page.</p><h3><strong>2. Look</strong></h3><p>The next is how the different elements are displayed on the web page. A website that has information is great but a website that displays this information in an attractive manner is even better. This part is known as CSS.</p><p>What is CSS?</p><p>Cascading Style Sheets (CSS) is used to style a HTML document.</p><h3><strong>3. Function</strong></h3><p>Finally, everyone is attracted towards a website that looks good but what about functionality? Enter JavaScript / TypeScript. In this series, we will focus on JavaScript (JS).</p><p>What is JS?</p><p>JavaScipt (JS) is a high-level programming language that conforms to the ECMAScript standard. It is used with HTML and CSS to breathe functionality into a webpage.</p><p>I’ve broken it down into a 3 part series. This article will cover the first part: HTML.</p><h3>Tools required</h3><ul><li><strong>Computer</strong></li><li><strong>Text Editor of choice (</strong>I love MS VS Code!)</li><li><strong>Browser</strong> (I always use Chrome)</li><li><strong>Browser Developer tools</strong> (In my case — Chrome Developer Tools)</li></ul><h3>Source code</h3><p>You can get the source code for the app <a href="https://github.com/ashtonfernandes/mern-stack">here</a>.</p><blockquote>Let’s get started!</blockquote><h3>Section 1: Elements</h3><p>HTML documents consist of nested HTML elements. The elements consists of the following:</p><ul><li>Opening tag — This is mandatory</li><li>Attributes — This is optional</li><li>Content</li><li>Closing tag — This is optional</li></ul><p>It has the following syntax:</p><pre>&lt;element tag attribute=&quot;type:value&quot;&gt;Content&lt;/element&gt;</pre><p>For example:</p><pre>&lt;h1&gt;Hello&lt;/h1&gt;</pre><p>We use the &lt;h1&gt; tag which is a Header 1 tag to display a h1 header. Let’s break this down:</p><ul><li><strong>Opening tag</strong>: &lt;h1&gt;</li><li><strong>Content</strong>: Hello</li><li><strong>Closing tag</strong>: &lt;/h1&gt;</li></ul><p>Notice the forward slash (“/”) in the closing tag which is used to indicate the end of an element in a closing tag to the web browser.</p><p>Some HTML elements are considered self closing so they do not have a closing tag. For example:</p><pre>&lt;br /&gt;</pre><p>The example above is that of a break. The <strong>&lt;br /&gt;</strong> tag is used to add a break to the web page at the specified location.</p><h3>Section 2: Attributes</h3><p>HTML attributes are used to define the behaviour of HTML elements.</p><p>It has the following syntax:</p><pre>&lt;element attribute=&quot;type:value&quot;&gt;Content&lt;/element&gt;</pre><p>An example:</p><pre>&lt;h1 style=&quot;color:blue;&quot;&gt;Hello&lt;/h1&gt;</pre><p>In the example above, we are using something called in-line CSS. This is used to style a particular element on the web page. We will go into the details of this in Part 2 of the Introduction to Web Development series. In this example, we are setting the colour of the font to blue using attributes</p><h3>Section 2.1: HTML Class</h3><p>The HTML class attribute is a way of giving HTML elements a classname. An element can have one or many classnames. The specified class name(s) will be used to add styling to the given element using CSS.</p><p>An example would be:</p><pre>&lt;h1 class=&quot;header&quot;&gt;Hello&lt;/h1&gt;</pre><p>In the example above, we are assigning the class header to the selected h1 element. Whatever style is described in the header class using CSS or functionality using JavaScript will be applied to this h1 element.</p><p>An element can have more than one class. An example would be:</p><pre>&lt;h1 class=&quot;className1 className2&quot;&gt;Hello&lt;/h1&gt;</pre><p>In the example above, we are assigning two classes: <strong>className1</strong> and <strong>className2</strong>, to the h1 element. Whatever style is described in the header and text classes using CSS will be applied to this h1 element. We will go into more details in Part 2 and Part 3 of this series.</p><h3>Section 2.2: HTML Id</h3><p>The HTML id attribute is a way of giving a HTML element a unique id. A selected if can only be used once on a webpage. This id will be used to add styling to the given element using CSS or functionality using JavaScript. We will go into more details in Part 2 and Part 3 of this series.</p><p>An example would be:</p><pre>&lt;h1 id=&quot;header&quot;&gt;Hello&lt;/h1&gt;</pre><p>In the example above, we are assigning the id: <strong>header</strong>, to the h1 element. Whatever style is described in the header class using CSS will be applied to this h1 element.</p><h3>Section 3: Tags</h3><p>HTML tags are used to define how the HTML will be formatted and displayed on the screen using a web browser.</p><p>As covered earlier, the HTML tag structure is as follows:</p><ul><li>Opening tag — This is mandatory</li><li>Attributes — This is optional</li><li>Content</li><li>Closing tag — This is optional</li></ul><p>There are many types of tags. Some common examples include:</p><ul><li>&lt;html&gt;</li><li>&lt;head&gt;</li><li>&lt;body&gt;</li><li>&lt;style&gt;</li><li>&lt;div&gt;</li></ul><p>There are many tags and these are essentially used to format the hTML that will be displayed on the screen.</p><h3>Section 4 : Creating a simple web page</h3><p>Now, it’s time to put all our knowledge into use. Let’s create a web</p><h3>Section 4.1: Create the HTML file</h3><p>First, let’s create a folder on your Desktop named “Scripts”. Next, create a file in this folder named “index.html”. This will be the source file that we will get started with.</p><p>Next, open this “index.html” file using the text editor (MS VS Code in my case). Place the following code to create a HTML page:</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Perfect, now we have our HTML file. This is the file that we will be using to run our JavaScript code eventually.</p><h3>Section 4.2: Hello World!</h3><p>Within the &lt;body&gt; section enter the following:</p><pre>&lt;body&gt;<br>     &lt;script&gt;<br>     &lt;/script&gt;<br>&lt;/body&gt;</pre><p>It is in this section that you will place your JavaScript code.</p><p>In between the script tag, enter the following:</p><pre>&lt;body&gt;<br>     &lt;script&gt;<br>          Hello World!<br>     &lt;/script&gt;<br>&lt;/body&gt;</pre><p>Basically, we are telling the program to display “Hello world!” on the web page.</p><p>Now, you should have something that looks like this:</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;script&gt;<br>          Hello World!<br>     &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>But how do we run this… Simple! You have to open the “index.html” file using your web browser. If everything went according to plan, you will see the “Hello world!” displayed on the web page.</p><h3>Section 4.3: A simple web page</h3><p>Now, we will be using some tags to divide the page. Let’s get rid of everything within the &lt;body&gt;. Your code should look like this:</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>We will start by writing all our code in the &lt;body&gt; section. Let’s divide the body into three sections using 3 divisions (div) :</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;div class=&quot;header&quot;&gt;&lt;/div&gt;<br>     &lt;div class=&quot;body&quot;&gt;&lt;/div&gt;<br>     &lt;div class=&quot;footer&quot;&gt;&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Now that we have divided the body into 3 sections and given each section a unique class name, we can add some text to each section.</p><p>Let’s work with the header first.</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;div class=&quot;header&quot;&gt; This is the Header &lt;/div&gt;<br>     &lt;div class=&quot;body&quot;&gt;&lt;/div&gt;<br>     &lt;div class=&quot;footer&quot;&gt;&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Now, we can work with the body.</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;div class=&quot;header&quot;&gt; This is the Header &lt;/div&gt;<br>     &lt;div class=&quot;body&quot;&gt; This is the Body &lt;/div&gt;<br>     &lt;div class=&quot;footer&quot;&gt;&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Next, we can work with the footer.</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;div class=&quot;header&quot;&gt; This is the Header &lt;/div&gt;<br>     &lt;div class=&quot;body&quot;&gt; This is the Body &lt;/div&gt;<br>     &lt;div class=&quot;footer&quot;&gt; This is the Footer&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Finally, let’s add some styling to the three divisions using attributes:</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>     &lt;meta charset=&quot;UTF-8&quot;&gt;<br>     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>     &lt;title&gt;Document&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>     &lt;div class=&quot;header&quot; style=&quot;color:blue;&quot;&gt; This is the Header &lt;/div&gt;<br>     &lt;div class=&quot;body&quot; style=&quot;red;&quot;&gt; This is the Body &lt;/div&gt;<br>     &lt;div class=&quot;footer&quot; style=&quot;green;&quot;&gt; This is the Footer&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>There you go, you have created a simple HTML page. In Part 2 of this series, we will go over the basics of CSS and how to improve the look of this website. Finally, in the Part 3 of this series, we will functionality to this web page using JavaScript.</p><h3>Part 8: References</h3><p><a href="https://en.wikipedia.org/wiki/HTML">https://en.wikipedia.org/wiki/HTML</a></p><p><a href="https://www.w3schools.com/css/">https://www.w3schools.com/css/</a></p><p><a href="https://www.w3schools.com/html/html_elements.asp">https://www.w3schools.com/html/html_elements.asp</a></p><p><a href="https://www.javatpoint.com/html-attributes">https://www.javatpoint.com/html-attributes</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71a52e9a53c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The MERN Stack with Redux]]></title>
            <link>https://medium.com/@ashton.s.fernandes/the-mern-stack-with-redux-fbd2a1400fa?source=rss-eecbc557431e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbd2a1400fa</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ashton Fernandes]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 05:12:00 GMT</pubDate>
            <atom:updated>2019-02-04T22:18:09.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lvf2N9JlPCPKgYk6" /><figcaption>“river during golden hour” by <a href="https://unsplash.com/@juanpoe?utm_source=medium&amp;utm_medium=referral">Richard Price</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve been looking for good tutorials that covers crating an application using the whole MERN stack and Redux from scratch. I found some really good ones but not everything I wanted was in one tutorial. So, I decided to make one and share it with you all. The purpose of this tutorial is to give you all a good understanding of the whole build process and introduce you to all the different technologies used.</p><p>In this article, we are going to build a simple web application using the following technologies:</p><ul><li><strong>MongoDB</strong>: NoSQL database</li><li><strong>Mongoose</strong>: MongoDB object modeling tool designed to work in an asynchronous environment</li><li><strong>Express.js</strong>: Back-end framework for building APIs</li><li><strong>React.js</strong>: Front-end library for building UIs</li><li><strong>Node.js</strong>: Back-end JavaScript runtime engine</li><li><strong>Redux</strong>: State management for React app</li><li><strong>Webpack</strong>: Module bundler</li><li><strong>Babel</strong>: Transpiler to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments</li></ul><p>The tools we will be using while building this application are:</p><ul><li><strong>Microsoft Visual Studio Code</strong> (or any other text editor of your choice — I love MS VS Code!)</li><li><strong>Postman</strong>: Used to test the different endpoints</li></ul><h3>Source code</h3><p>You can get the source code for the app <a href="https://github.com/ashtonfernandes/mern-stack">here</a>.</p><h3>Why React<strong>.js</strong>?</h3><p>React.js is an awesome and extremely powerful JavaScript UI library. Some of the key benefits of using React.js are:</p><ol><li>Uni-directional data flow</li><li>Components</li><li>The Virtual DOM</li><li>Extremely compatible with various other libraries</li></ol><h3>Why Node<strong>.js</strong>?</h3><p>Node.js is an open-source JavaScript run-time environment that executes JavaScript code outside the browser. Some of the key benefits of using Node.js are:</p><ol><li>Extremely fast</li><li>Real-Time</li><li>Cross-platform</li><li>Npm</li><li>Easy to learn</li><li>JavaScript based</li></ol><h3>Environment Setup</h3><p>The web application consist of two parts: Front-end and back-end. The front-end is built using React.js and Redux, while the back-end part is built using Node.js and Express.js. We will also be using Webpack as our open-source JavaScript module bundler. Let’s break this down into two stages:</p><ol><li>Server setup</li><li>Client setup</li></ol><h3>Part 1: Creating the app</h3><ol><li>Create a new directory</li><li>In the terminal in that directory, let’s initialize the directory using the following command:</li></ol><pre>npm init</pre><p>3. Enter a name (Hit Enter to select default or enter the name of the application)</p><p>4. Enter a version (Hit Enter to select default or enter the version of the application)</p><p>5. Enter a description</p><p>4. Enter “src/server/server.js” as the entry point for the back-end(root of the source code)</p><p>5. Hit Enter on each subsequent step to select the default values</p><p>5. This should create a package.json file in your directory</p><h3>Part 2: Setting up the Node.js server</h3><p>We are going to start by building an Express API to interact using mongoose to interact with MongoDB. We are going to install dependencies we need:</p><ul><li>express: Back-end framework</li><li>body-parser: Needed to handle the data that comes from the server</li><li>mongoose: ORM to interact with MongoDB</li><li>concurrently: To run more than one npm script at a time (server and client at the same time)</li></ul><pre>npm i express body-parser mongoose concurrently</pre><p>We are going to install some development dependencies:</p><ul><li>nodemon: Utility to monitor for any changes in your source and automatically restart your server</li></ul><pre>npm i -D nodemon</pre><p>Now, time for SCRIPTS! Let’s add a few scripts in your package.json file now.</p><p>The first script we’ll add is a start script. We add “NODE_ENV=production” to the start of the script to let the environment know to run the app in production mode:</p><pre>&quot;start&quot;: &quot;NODE_ENV=production node ./src/server/server.js&quot;</pre><p>For our development script, we want to use nodemon to monitor for changes so we don’t have to keep restarting our server when we change something. We add “NODE_ENV=development” to the start of the script to let the environment know to run the app in development mode:</p><pre>&quot;server&quot;: &quot;NODE_ENV=development nodemon ./src/server/server.js&quot;</pre><p>Let’s create a folder named src in the root of your application. This folder will contain two additional folder:</p><ol><li>server: This is where all the server side code will reside (back-end code)</li><li>client: This is where all the client side code will reside (front-end code)</li></ol><p>Now for the MongoDB database, you can use a free one hosted locally or you can use a free one that is available online. For this application, I decided to use one that is available online for free (<a href="https://mlab.com/">MLab</a>). Go ahead and signup for a free account. After verifying you email, you can start using this service.</p><p>To create a new database instance on mLab:</p><ol><li>Click on <strong>Create new</strong></li><li>Select your preferred <strong>Cloud provider</strong>. I selected Amazon Web Services</li><li>Select your preferred <strong>Plan Type</strong>. I selected SANDBOX as it’s free.</li><li>Select your <strong>Region</strong></li><li>Enter a <strong>Database Name</strong></li><li>Submit the free order and you should be able to access your database</li><li>Create a database user by clicking <strong>Add database user</strong></li><li>Copy the <strong>MongoDB_URI</strong> provided at the top of the page</li></ol><p>Next, let’s create a folder in the root of your application named config. Inside that folder, create a file names keys.js. In this file, we will be adding the following code:</p><pre>module.exports = {<br>  mongodbURI: &#39;&lt;MongoDB_URI&gt;&#39;<br>}</pre><p>Ensure that you have quotes around the URI and that the <strong>&lt;dbuser&gt;</strong> is the username you set up and <strong>&lt;dbpassword&gt;</strong> is the password you set up for the user.</p><p>Next, we need to configure MongoDB in our server.js file:</p><pre>const db = require(&#39;../../config/keys&#39;).mongodbURI;</pre><p>Next, we need to connect to MongoDB:</p><pre>mongoose.connect(db, { useNewUrlParser: true })<br>  .then(() =&gt; console.log(&#39;DB connected&#39;))<br>  .catch((err) =&gt; console.log(&#39;DB error&#39;, err))</pre><p>Next, we define the port number. If in production, we want to use the port specified by the platform we have deployed our application on. If you run locally, you can set the default port number to be 3000:</p><pre>const port = process.env.PORT || 3000;</pre><p>Next, we wan our app to listen on this port:</p><pre>app.listen(port, () =&gt; console.log(`App listening on port ${port}`));</pre><p>Now, we come to the part where we check the node environment. If the environment is production, we want to ensure that user is redirected to https instead of http. We can ensure this happens by adding the following piece of code in server.js:</p><pre>if (process.env.NODE_ENV === &#39;production&#39;) { <br>  app.enable(&#39;trust proxy&#39;); <br>  app.use((req, res, next) =&gt; { <br>    if (req.secure) next();<br>    else res.redirect(`https://&#39;${req.headers.host}${req.url}`);<br>  });<br>}</pre><p>Let’s test our app now locally (dev environment) by running the dev script in the terminal in that directory:</p><pre>npm run server</pre><p>You should see two messages printed out in the console that shows you that the app has started and that the DB is connected:</p><pre>App listening on port 3000<br>DB connected</pre><blockquote>Awesome, we now have our server ready!</blockquote><h3>Part 3: Creating the database schema</h3><p>What is a database schema? The database schema of a database system is its structure described in a formal language supported by the database management system (DBMS). The term “schema” refers to the organization of data as a blueprint of how the database is constructed (divided into database tables in the case of relational databases).</p><p>Let’s start with creating the schema. Create a new folder in the server folder inside src named models. In that folder, create a file named Item.js. In Item.js, add the following code:</p><pre>const mongoose = require(&#39;mongoose&#39;);</pre><pre><em>// mongoose schema<br></em>const Schema = mongoose.Schema;</pre><pre><em>// create a schema<br></em>const ItemSchema = new Schema({<br>  name: {<br>       type: String,<br>       required: true<br>  },<br>  date: {<br>       type: Date,<br>       default: Date.now<br>  }<br>})</pre><h3>Part 4: Creating the database model</h3><p>What is a database model? A database model is a type of data model that determines the logical structure of a database and fundamentally determines in which manner data can be stored, organized and manipulated.</p><p>We now need to create a model for our data. Let’s create a model and export it:</p><pre>module.exports = Item = mongoose.model(&#39;item&#39;, ItemSchema);</pre><h3>Part 5: Setting up the different routes</h3><p>What is Routing? Routing is basically a way for the back-end endpoints to react and respond to the different request from the front-end.</p><p>How does this request look like though? It pretty much is a URI and a HTTP request method.</p><p>We need to create a folder where we can save all the different API routes. We don’t want to do this in server.js as this would clutter this file. We want to make this project as modular as possible One of the key benefits being that if somebody else were to look at this code, it would be extremely easy to understand and start working on it.</p><p>Time to separate our our routes. Create a folder in the server folder inside src named routes. Inside this folder, create another folder named api. Inside the api folder, create a file named items.js. Firstly, in this file, we need to import the express router:</p><pre>const router = require(&#39;express&#39;).Router();</pre><p>Secondly, we need to import the Item model. This is required in order to create the different queries we will be creating to interact with the database:</p><pre>const Item = require(&#39;../../models/Item&#39;);</pre><p>Lastly, we need to export the router:</p><pre>module.exports = router;</pre><p>Now, let’s import this file, in our server.js file:</p><pre>const items = require(&#39;./routes/api/items&#39;);</pre><p>Since, we have our schema and model setup, we can move on to creating our routes. This will be done in items.js. The way each route is setup looks like this:</p><pre>router.get(&#39;/&#39;, (req, res) =&gt; {<br>  <em>// ModelName.method<br>  // It will return a promise<br>  // Do something with that data that is returned from the database or is in the database<br></em>})</pre><p>Let’s setup the main CRUD Operations! What is CRUD?</p><p>C: Create</p><p>R: Read</p><p>U: Update</p><p>D: Delete</p><p>Why CRUD? These are the basic operations that a simple web application needs to achieve when dealing with data in a database.</p><p>(R: Read) First, let’s let’s setup an endpoint to grab all the data (which is none at the moment) from the database. We will be using the mongoose find method. You can find additional information about this method <a href="https://mongoosejs.com/docs/api.html#query_Query-find">here</a>. We will be using the router GET method:</p><pre>router.get(&#39;/&#39;, (req, res) =&gt; { <br>  Item.find()<br>    .then(items =&gt; res.json(items)) <br>})</pre><p>(C: Create) Next, let’s create a new endpoint to post data to the database. We will be using the mongoose save method. You can find additional information about this method <a href="https://mongoosejs.com/docs/api.html#model_Model-save">here</a>. We will be using the router POST method:</p><pre>router.post(&#39;/&#39;, (req, res) =&gt; {<br>  const itemToPost = new Item({ <br>    name: req.body.name <br>  }); <br>  itemToPost.save() <br>    .then(item =&gt; <br>      res.json(item)) <br>})</pre><p>(U: Update) Lastly, let’s setup an endpoint to update a particular item in the database. First we need to find the item in the database using the mongoose find method. If the item cannot be found, we want to return a 404 error. Then, we want to update that particular item using the mongoose update method. We will be using the router PUT method:</p><pre>router.put(&#39;/:id&#39;, (req, res) =&gt; {<br>  Item.findById(req.params.id)<br>    .then(item =&gt; {<br>      item.update()<br>        .then(() =&gt; res.json({ success: true }))<br>        <em>// return 404 if not found<br>        </em>.catch(err =&gt; res.status(404).json({ success: false }) )<br>    })<br>})</pre><p>(D: Delete) Next, let’s setup an endpoint to delete a particular item in the database. First we need to find the item in the database using the mongoose find method. If the item cannot be found, we want to return a 404 error. Then, we want to delete that particular item using the mongoose remove method. We will be using the router DELETE method:</p><pre>router.delete(&#39;/:id&#39;, (req, res) =&gt; {<br>  Item.findById(req.params.id)        <br>    .then(item =&gt; {            <br>      item.remove()                <br>      .then(() =&gt; res.json({ <br>        success: true }))                <br>      // return 404 if not found                <br>      .catch(err =&gt; res.status(404).json({ success: false }) )    <br>    }) <br>})</pre><blockquote>Now that we have our different endpoints setup, let’s test them out!</blockquote><h3>Part 6: Testing the different routes</h3><p>Now that we have our endpoints setup, we can test to see if it works using postman. Install the client from <a href="https://www.getpostman.com/">here</a>. Postman is an awesome tool and super easy to use!</p><ol><li>Test the first endpoint to post data in the database.</li></ol><p>In the input field at the top, enter the endpoint and make sure it’s a POST request. Then, under the body tab, select raw. From the dropdown, select JSON(application/json) and then enter the following:</p><pre>{<br>  &quot;name&quot;: &quot;Item 1&quot;<br>}</pre><p>Click on Send and you should see a successful post. How do you know if the call was successful? You check the HTTP status code. In the image below, you can see that the Status is <strong>200 OK</strong>. This signifies that the call was successful. We can do this step twice to add two items in the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRlPGRVgj40bCRrzuv36lg.png" /></figure><p>Also, in mLab, you should see a new entry under Collections:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*doqbIL4t8Q7lrRrgSz2abg.png" /></figure><p>2. Test the second endpoint to find all the items in the database</p><p>In the input field at the top, enter the endpoint and make sure it’s a GET request. Then click on Send and you should get the object that you just created in the database in the step above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oAWdFzoRNEFexQisem5GoA.png" /></figure><p>3. Test the third endpoint to delete an item in the database</p><p>Grab the id from the response of the second endpoint in Postman and append that the the URI in the input field. Ensure that it is a DELETE request. Hit Send and you should get a successful response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SYSxaqlAzzpxirHocePFNQ.png" /></figure><p>To ensure that the item did in fact get deleted from the database, do a get all item request and you should see only one item:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDdn42ojtAhNLi4fLU0O2Q.png" /></figure><p>4. Test the last endpoint to update an item to the database</p><p>Grab the id from the response of the second endpoint in Postman and append that the the URI in the input field. Ensure that it is a PUT request. In the body, enter an updated name. Hit Send and you should get a successful response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHj6YWo5euO69SwCZUHeNw.png" /></figure><p>To ensure that the item did in fact get updated in the database, do a get all item request and you should see the updated name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDrkT85Ra8rVO1EAFUP3_A.png" /></figure><blockquote>Awesome, now that we have all our endpoints created and tested, we can move onto the next step!</blockquote><h3>Part 7: Setting up the React.js client</h3><p>We are going to install dependencies we need:</p><ul><li>react</li><li>react-dom</li><li>react-router-dom</li></ul><pre>npm i react react-dom react-router-dom</pre><h3>Part 8: Configuring Babel</h3><p>We will need to use a transpiler like babel to compile es6 code to es5 code, which can be understood by the browser.</p><p>We will also be installing some dev dependencies:</p><ul><li>babel</li><li>babel-cli</li><li>babel-core</li><li>babel-loader (version 7 at the time as version 8 is not fully compatible)</li><li>babel-plugin-transform-class-properties</li><li>babel-plugin-transform-object-rest-spread</li><li>babel-preset-env</li><li>babel-preset-es2015</li><li>babel-preset-react</li><li>transform-class-properties</li><li>transform-object-rest-spread</li></ul><pre>npm i -D babel babel-cli babel-core babel-loader@7.0.0 babel-plugin-transform-class-properties babel-plugin-transform-object-rest-spread babel-preset-env babel-preset-es2015 babel-preset-react transform-class-properties transform-object-rest-spread</pre><p>In the root of your directory, create a file named .bablerc and inside this file, inset the following code:</p><pre>{<br>  &quot;presets&quot;: [<br>    &quot;react&quot;,<br>    &quot;es2015&quot;<br>  ],<br>  &quot;plugins&quot;: [<br>    &quot;transform-class-properties&quot;,<br>    &quot;transform-object-rest-spread&quot;<br>  ]<br>}</pre><p>This file is our configuration for Babel. We define the preset environments: react and es2015.</p><p>We also use two plugins:</p><ol><li>transform-class-properties</li></ol><p>This is required to use es6 arrow functions. Without this class, we would get an error while using es6 arrow functions.</p><p>2. transform-object-rest-spread</p><p>This is required to use the spread operator (…)with objects. By default, it works with arrays, but in order to make it work with objects, we need this class.</p><h3>Part 9: Setting up Webpack</h3><p>We will also be installing some dev dependencies:</p><ul><li>webpack</li><li>webpack-cli</li><li>clean-webpack-plugin</li><li>html-webpack-plugin</li><li>style-loader</li><li>css-loader</li></ul><pre>npm i -D webpack webpack-cli clean-webpack-plugin html-webpack-plugin style-loader css-loader</pre><p>In the root of your application, create a webpack.config.js file. This is your webpack configuration file. Let’s go a little deep into webpack:</p><ul><li>entry: An entry point indicates which module webpack should use to begin building out its internal <em>dependency graph</em>. Webpack will figure out which other modules and libraries that entry point depends on (directly and indirectly)</li><li>output: The output property tells webpack where to emit the <em>bundles</em> it creates and how to name these files. It defaults to ./dist/main.js for the main output file and to the ./dist folder for any other generated file</li><li>Loaders: Out of the box, webpack only understands JavaScript files. Loaders allow webpack to process other types of files and convert them into valid modules that can be consumed by your application and added to the dependency graph</li><li>Plugins: While loaders are used to transform certain types of modules, plugins can be leveraged to perform a wider range of tasks like bundle optimization, asset management and injection of environment variables</li><li>clean-webpack-plugin: Webpack plugin to remove the build folder(s) before building</li><li>html-webpack-plugin: Simplifies creation of HTML files to serve your webpack bundles. It loads the template (public/index.html) and injects the output bundle</li></ul><p>Here you include the following in your webpack.config.js file:</p><pre>const path = require(&quot;path&quot;);<br>const webpack = require(&quot;webpack&quot;);<br>const HtmlWebpackPlugin = require(&quot;html-webpack-plugin&quot;);<br>const CleanWebpackPlugin = require(&quot;clean-webpack-plugin&quot;);</pre><pre>module.exports = {<br>  entry: &quot;./src/client/index.js&quot;,<br>  output: {<br>    path: path.join(__dirname, &quot;dist&quot;),<br>    publicPath: &#39;/&#39;,<br>    filename: &quot;bundle.js&quot;<br>  },<br>  module: {<br>    rules: [<br>      {<br>        test: /\.(js|jsx)$/,<br>        exclude: /node_modules/,<br>        use: {<br>          loader: &quot;babel-loader&quot;<br>        }<br>      },<br>      {<br>        test: /\.css$/,<br>        use: [&quot;style-loader&quot;, &quot;css-loader&quot;]<br>      }<br>    ]<br>  },<br>  devServer: {<br>    port: 3000,<br>    open: true,<br>    proxy: {<br>      &quot;/api&quot;: &quot;http://localhost:8080&quot;<br>    }<br>  },<br>  plugins: [<br>    new CleanWebpackPlugin([&quot;dist&quot;]),<br>    new webpack.HashedModuleIdsPlugin(),<br>    new HtmlWebpackPlugin({<br>      title: &quot;Boilerplate&quot;,<br>      template: &quot;index.ejs&quot;,<br>      minify: {<br>        collapseWhitespace: true,<br>        collapseInlineTagWhitespace: true,<br>        removeComments: true,<br>        removeRedundantAttributes: true<br>      }<br>    }),<br>  ]<br>  mode: &quot;production&quot;<br>};</pre><p>Next, we create a template for the index.html file. Create a file name index.ejs in the root of your application and inside it, insert the following code:</p><pre>&lt;!doctype html&gt;<br>  &lt;html&gt;<br>    &lt;head&gt;<br>    &lt;meta <em>charset</em>=&quot;utf-8&quot;&gt;<br>    &lt;meta <em>name</em>=&quot;apple-mobile-web-app-capable&quot; <em>content</em>=&quot;yes&quot; /&gt;<br>    &lt;meta <em>name</em>=&quot;viewport&quot; <em>content</em>=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0&quot; /&gt;<br>    &lt;title&gt;&lt;%= htmlWebpackPlugin.options.title %&gt;&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;div <em>id</em>=&quot;root&quot;&gt;&lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Next, we have to create a folder for the client side code. Create a folder inside src named client. Inside the client folder, create a file named index.js. Inside this file, add the following code:</p><pre><em>import</em> React <em>from</em> &#39;react&#39;;<br><em>import</em> ReactDOM <em>from</em> &#39;react-dom&#39;;<br><em>import</em> App <em>from</em> &#39;./App&#39;;</pre><pre>ReactDOM.render(&lt;App /&gt;, document.getElementById(&#39;root&#39;));</pre><p>Next, the the client folder, create a file named App.js. Add the following contents:</p><pre>import React, { Component } from &#39;react&#39;;</pre><pre>export default class App extends Component {  <br>  constructor(props) {    <br>    super(props);    <br>    this.state = { <br>    };  <br>  }</pre><pre>render() {    <br>    return (      <br>      &lt;div&gt; Hello World! &lt;/div&gt;<br>    )<br>  }<br>}</pre><p>Now, we have to make some adjustment in the server.js code in order to server the static files for your Front-end. In server.js, you have to add the path to your dist folder (public directory) generated by webpack:</p><pre>const PUBLIC_DIR = process.cwd() + &#39;/dist&#39;;</pre><p>Then, you have to serve the static files (JavaScript files, CSS files, etc.):</p><pre>app.use(express.static(PUBLIC_DIR));</pre><p>Next, we create a folder named assets in the client folder. This is where we store all the different assets to be used in this project.</p><h3>Part 10: Installing our CSS frameworks</h3><p>We will install and incorporate Bootstrap in our project. Installing a CSS library helps in building the UI. You can get more information about Bootstrap <a href="https://getbootstrap.com/">here</a>. We also need to install Reactstrap. You need it as Bootstrap allows us to use the different components but Reactstrap allows us to use Bootstrap components as React components. You can get more information about Reactstrap <a href="https://reactstrap.github.io/">here</a>.</p><p>Installing them:</p><pre>npm i bootstrap reactstrap</pre><p>Next, we need to import it within our project. In App.js, add the following line of code:</p><pre>import &#39;bootstrap/dist/css/bootstrap.min.css&#39;;</pre><h3>Part 11: Creating components</h3><p>Now, we will create the different components for our application. In the client folder, create another folder called components. This is where we store all the different React components. Anything that can be reused, for example, the nav bar, the footer, etc., we will create reusable components. This way we don’t have to keep rewriting code. This is one of the features of React I love the best. This makes writing code so much more efficient and saved a lot of time!</p><p>First, we start off by creating the Header. In the components folder, create a folder named Header and inside that folder, create a file named Header.js. We will be using reactstrap to build our nav bar. You can have a look at the example code for using the reactstarp Navbar <a href="https://reactstrap.github.io/components/navbar/">here</a>. I copied this example code into Navbar.js and stripped off the blocks of code that I don’t need. I also converted the function into an es6 arrow function:</p><pre>import React, { Component } from &#39;react&#39;; <br>import { <br>  Collapse, <br>  Navbar, <br>  NavbarToggler, <br>  NavbarBrand, <br>  Nav, <br>  NavItem, <br>  NavLink<br>} from &#39;reactstrap&#39;;</pre><pre>class Header extends Component { <br>  constructor(props) { <br>    // need super to call the parent&#39;s class constructor <br>    super(props); <br>    this.state = { <br>      isOpen: false <br>    }; <br>  }</pre><pre>toggle = () =&gt; { <br>    this.setState({ <br>      isOpen: !this.state.isOpen <br>    }); <br>  }</pre><pre>render() { <br>    return ( <br>      &lt;div&gt; <br>        &lt;Navbar color=&quot;light&quot; light expand=&quot;md&quot; className=&quot;mb-5&quot;&gt;   <br>          &lt;NavbarBrand href=&quot;/&quot;&gt;MERN Stack&lt;/NavbarBrand&gt; <br>          &lt;NavbarToggler onClick={this.toggle} /&gt; <br>          &lt;Collapse isOpen={this.state.isOpen} navbar&gt; <br>            &lt;Nav className=&quot;ml-auto&quot; navbar&gt;<br>              &lt;NavItem&gt; <br>                &lt;NavLink href=&quot;<a href="https://github.com/ashtonfernandes/mern-stack">https://github.com/ashtonfernandes/mern-stack</a>&quot;&gt;GitHub<br>                &lt;/NavLink&gt; <br>              &lt;/NavItem&gt; <br>            &lt;/Nav&gt; <br>          &lt;/Collapse&gt; <br>        &lt;/Navbar&gt; <br>      &lt;/div&gt; <br>    ); <br>  } <br>} <br>export default Header;</pre><p>Next, we import the Header into our App.js file:</p><pre><em>import</em> Header <em>from</em> &#39;./components/Header/Header&#39;;</pre><p>Then we use it inside App.js inside the return div:</p><pre>&lt;Header /&gt;</pre><p>Now, go to localhost:3000 in your web browser and you should see your application and the nav bar at the top.</p><h3>Part 12: Installing Redux</h3><p>We are going to install dependencies we need:</p><ul><li>redux</li><li>react-redux</li><li>redux-devtools-extension</li><li>redux-thunk</li></ul><pre>npm i redux react-redux redux-devtools-extension redux-thunk</pre><p>Next, in your client folder inside src, create a folder named store.js. In this file we will configure the react store. What exactly does the store do? Well, it basically holds the whole state tree of our application. More information can be found <a href="https://redux.js.org/api/store">here</a>. Let’s get started by importing our dependencies:</p><pre><em>import</em> { createStore, applyMiddleware } <em>from</em> &#39;redux&#39;;<br><em>import</em> thunk <em>from</em> &#39;redux-thunk&#39;;<br><em>import</em> { composeWithDevTools } <em>from</em> &#39;redux-devtools-extension&#39;;</pre><p>We also need a way to use multiple reducers in our code. For this application, I will demonstrate only using a single reducer, but in reality, most applications have more than one reducer. A way to use multiple reducers is to combine all the reducers in one file and use the combineReducers function to turn an object whose values are different reducing functions into a single reducing function. We will call the file that has all the different reducers RootReducer.js and place it in a folder named RootReducer inside the client folder in src</p><pre><em>import</em> rootReducer <em>from</em> &#39;./RootReducer/RootReducer&#39;;</pre><p>Then, we set the initial state of our store and the redux middleware. We are using Redux thunk as our middleware to dispatch the actions to our reducers which will eventually change our app state. We then want to create the store and export it:</p><pre>const initialState = {};<br>const middleWare = [thunk];</pre><pre>const store = createStore(rootReducer, initialState, composeWithDevTools(applyMiddleware(...middleWare)));</pre><pre><em>export</em> <em>default</em> store;</pre><p>In RootReducer.js, inset the following code:</p><pre><em>import</em> { combineReducers } <em>from</em> &#39;redux&#39;;</pre><pre><em>export</em> <em>default</em> combineReducers({<br>})</pre><p>Now that we have our store created, we want to import in in App.js.:</p><pre><em>import</em> store <em>from</em> &#39;./store&#39;;</pre><p>We need to make the store available to all container components in the application without passing it explicitly. We achieve this by using Provider from react-redux. So, we need to import the Provider from react-redux in App.js:</p><pre><em>import</em> { Provider } <em>from</em> &#39;react-redux&#39;;</pre><p>We then wrap our App in App.js with the Provider and set the store to the store we created:</p><pre>&lt;Provider store={store}&gt;<br>  &lt;div&gt;<br>    &lt;AppNavbar /&gt;<br>  &lt;/div&gt;<br>&lt;/Provider&gt;</pre><p>Go to your browser and test to make sure your app is not broken by going to <a href="http://localhost:3000/">http://localhost:3000/</a></p><p>Now, we create another folder in the client folder named types. Inside this folder, create a file named types.js. This file will include all the different types of actions that are to be performed within the application.</p><p>We now can complete setting up our rootReducer.js file. In this file, import the ListReducer (we will be setting it up in Part 13) and then use it within the combineReducers. We are doing this now so that the reducer is available for the List component we setup in Part 13:</p><pre><em>import</em> ListReducer <em>from</em> &#39;../components/List/ListReducer&#39;;</pre><pre><em>export</em> <em>default</em> combineReducers({<br>  list: ListReducer<br>})</pre><p>Next, let’s create a simple List component. The reason we are building a list is so that we can interact with the database. This way if you have to interact with the data in the database in any way, you have some experience and don’t get too confused!</p><h3>Part 13: Creating a List component</h3><p>Let’s create another folder in the components folder named List and inside that create a file named List.js. This component will display all the different items in the database. This list will also have the different features such as deleting or updating a particular task in the database. Inside this file, let’s first import our dependencies, then create the class and finally export it :</p><pre><em>import</em> React, { Component } <em>from</em> &#39;react&#39;;<br><em>import</em> { Container, ListGroup, ListGroupItem, Button } <em>from</em> &#39;reactstrap&#39;;<br><em>import</em> { CSSTransition, TransitionGroup } <em>from</em> &#39;react-transition-group&#39;;</pre><pre>class List extends Component {<br>  constructor(props) {<br>    <em>// need super to call the parent&#39;s class constructor<br>    super</em>(props);<br>    <em>this</em>.state = {<br>    }<br>  }</pre><pre>render() {<br>    <em>return</em> (<br>      &lt;Container&gt;<br>      &lt;/Container&gt;<br>    );<br>  }<br>}<br><em>export</em> <em>default</em> List;</pre><p>Now we have a very important step to complete. We have to connect our component to the Redux store. Why? To ensured that we are able to grab the application state from Redux. Itt also ensures that we can change the state based on our actions. The way this is possible is by using the connect function from react-redux.</p><p>To use the connect function from react-redux, you first need to define mapStateToProps. This is a function that tells how to transform the current Redux store state into the props you want to pass to a the component. Insert the following code at the bottom of List.js, right before exporting the component:</p><pre>const mapStateToProps = state =&gt; {<br>  return {<br>  }<br>}</pre><p>Next, you need to define mapDispatchToProps. This is a function that receives the dispatch() method and returns callback props that you want to inject into the component. Insert the following code after the mapStateToProps function in List.js:</p><pre>const mapDispatchToProps = dispatch =&gt; {<br>  return {<br>  }<br>}</pre><p>We need to now use the connect function. First, let’s import it from react-redux in List.js:</p><pre>import { connect } from &#39;react-redux&#39;;</pre><p>Next, we wrap our component using the connect function and provide it the two functions we defined (mapStateToProps and mapDispatchToProps):</p><pre><em>export</em> <em>default</em> connect(mapStateToProps, mapDispatchToProps)(List);</pre><p>Awesome, we now have our list class setup. Next, we have to setup our actions and reducer. Create two files inside the List folder named: ListActions.js and ListReducer.js. The actions file will contain all the different thunk actions and action generators. The reducer file will contain the list reducer (which is used to get or change the application state).</p><h3>Part 14: Setting up the Action types</h3><p>First in types.js, let’s define the different constants that will be used for the list:</p><pre>export const GET_ITEMS = &#39;GET_ITEMS&#39;;<br>export const ADD_ITEM = &#39;ADD_ITEM&#39;;<br>export const UPDATE_ITEM = &#39;UPDATE_ITEM&#39;;<br>export const DELETE_ITEM = &#39;DELETE_ITEM&#39;;</pre><h3>Part 15: Setting up the Actions</h3><p>Let’s import these types into our ListActions.js file:</p><pre>import { GET_ITEMS, ADD_ITEM, UPDATE_ITEM, DELETE_ITEM } <em>from</em> &#39;../../types/types&#39;;</pre><p>Let’s setup the action generators. This will basically be dependant on each of the different action types we imported:</p><pre><em>export</em> const getItems = () =&gt; {<br>  type: GET_ITEMS<br>}</pre><pre><em>export</em> const addItem = () =&gt; {<br>  type: ADD_ITEM<br>}</pre><pre><em>export</em> const updateItem = () =&gt; {<br>  type: UPDATE_ITEM<br>}</pre><pre><em>export</em> const deleteItem = () =&gt; {<br>  type: DELETE_ITEM<br>}</pre><h3>Part 16: Setting up the Reducer</h3><p>Let’s import these types into our ListReducer.js file:</p><pre>import { GET_ITEMS, ADD_ITEM, UPDATE_ITEM, DELETE_ITEM } <em>from</em> &#39;../../types/types&#39;;</pre><p>Now let’s setup the ListReducer. First, we need to define the initial state of the application. We will be mocking up 4 times for now. This is to just check to see if we are grabbing the state from redux. We will also need to import uuid to generate ids for each item. This is just done temporarily as the database defines a unique id for each item automatically:</p><pre><em>import</em> uuid <em>from</em> &#39;uuid&#39;;<br>const initialState = {<br>  items: [<br>    { id: uuid(), name: &#39;Item 1&#39; },<br>    { id: uuid(), name: &#39;Item 2&#39; },<br>    { id: uuid(), name: &#39;Item 3&#39; },<br>    { id: uuid(), name: &#39;Item 4&#39; }<br>  ]<br>};</pre><p>Next, we export a default function in the reducer. In this function, we will utilize switch cases so we can handle the different action types. This function will take in two parameters. First: the initial state that we defined. Second: action. In each case, we want to first return the state of the application. We used the spread operator so we return the previous state of the application and don’t overwrite it. Then, we return what we’re looking for. For now, we will only return the state of the application:</p><pre><em>export</em> <em>default</em> (state = initialState, action) =&gt; {<br>  <em>switch</em>(action.types) {<br>    <em>case</em> GET_ITEMS:<br>    <em>return</em> {<br>      ...state<br>    }<br>  <em>switch</em>(action.types) {<br>    <em>case</em> ADD_ITEM:<br>    <em>return</em> {<br>      ...state<br>    }<br>  <em>switch</em>(action.types) {<br>    <em>case</em> UPDATE_ITEM:<br>    <em>return</em> {<br>      ...state<br>    }<br>  <em>switch</em>(action.types) {<br>    <em>case</em> DELETE_ITEM:<br>    <em>return</em> {<br>      ...state<br>    }<br>  }<br>}</pre><h3>Part 17: Grabbing the value from the Redux store</h3><p>Let’s import the getItems function from ListActions.js into our component List.js:</p><pre><em>import</em> { getItems } <em>from</em> &#39;./ListActions&#39;;</pre><p>Next, we need to call this function when the component mounts. We do it in the componentDidMount function as that is probably the best time to grab the items form the redux store:</p><pre>componentDidMount = () =&gt; {<br>  <em>this</em>.props.getItems();<br>}</pre><p>If you noticed something, the way the function is called is by using this.props.functionName. The reason being is it passed down from redux as a prop in the mapDispatchToProps function.</p><p>Next, we need to get this function in our mapDispatchToProps function:</p><pre>const mapDispatchToProps = dispatch =&gt; {<br>  <em>return</em> {<br>    getItems<br>  }<br>}</pre><p>Finally, we need to get list as a prop from the redux store in list.js:</p><pre>const mapStateToProps = state =&gt; {<br>  <em>return</em> {<br>    <em>// The name items is based on the name what you will define it in the rootReducer<br>    </em>list: state.list<br>  }<br>}</pre><p>Now, we use es6 restructuring to define the items in our component render function. This declaration is done in the render function, but before the return function:</p><pre>const { items } = <em>this</em>.props.list;</pre><p>Finally, we need to map through the list and display each item in a table. We will be using react-transition-group for the different CSS transitions. So, now our render method in List.js will look a little different:</p><pre>render() { <br>  const { items } = this.props.list; <br>  return ( <br>    &lt;Container&gt; <br>      &lt;button <br>        color=&quot;dark&quot; <br>        style={{ marginBottom: &#39;2rem&#39; }} <br>        onClick={this.addItem}&gt;Add Item<br>      &lt;/button&gt;<br>      &lt;ListGroup&gt; <br>        &lt;TransitionGroup className=&quot;list&quot;&gt; <br>          {items.map(({id, name}) =&gt; ( <br>          &lt;CSSTransition key={id} timeout={200} classNames=&quot;fade&quot;&gt; <br>            &lt;ListGroupItem&gt; {name} <br>            &lt;/ListGroupItem&gt; <br>          &lt;/CSSTransition&gt; <br>          ))} <br>        &lt;/TransitionGroup&gt; <br>      &lt;/ListGroup&gt; <br>    &lt;/Container&gt; <br>  ); <br>}</pre><p>There you go, you now are grabbing the values from the redux store and displaying it in your application.</p><blockquote>So, here you go. We are all set up and you have a working application. Feel free to comment if you have any questions or concerns!</blockquote><h3>References</h3><p><a href="https://www.sourcetoad.com/app-development/the-benefits-of-using-react/">https://www.sourcetoad.com/app-development/the-benefits-of-using-react/</a></p><p><a href="https://think360studio.com/12-benefits-of-using-node-js-for-web-application/">https://think360studio.com/12-benefits-of-using-node-js-for-web-application/</a></p><p><a href="https://expressjs.com/en/starter/basic-routing.html">https://expressjs.com/en/starter/basic-routing.html</a></p><p><a href="https://mongoosejs.com/docs/connections.html">https://mongoosejs.com/docs/connections.html</a></p><p><a href="https://webpack.js.org/concepts/">https://webpack.js.org/concepts/</a></p><p><a href="https://redux.js.org/api/store">https://redux.js.org</a></p><p><a href="https://en.wikipedia.org/wiki/Database_schema">https://en.wikipedia.org/wiki/Database_schema</a></p><p><a href="https://en.wikipedia.org/wiki/Database_model">https://en.wikipedia.org/wiki/Database_model</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbd2a1400fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up CI/CD with an Enterprise GitHub Repository and a Node.js Web Application on Azure]]></title>
            <link>https://medium.com/@ashton.s.fernandes/setting-up-ci-cd-with-an-enterprise-github-repository-and-a-node-js-web-application-on-azure-5fbaa6a51839?source=rss-eecbc557431e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fbaa6a51839</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Ashton Fernandes]]></dc:creator>
            <pubDate>Wed, 08 Aug 2018 01:43:22 GMT</pubDate>
            <atom:updated>2019-02-08T01:54:36.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqKQi7OwUvGcq77xr3-U0Q.png" /></figure><blockquote>I was trying to hook up my Enterprise GitHub account with Azure so that I wouldn’t need to manually deploy my code to Azure each time. I tried following all the possible documentation available, but some steps worked and some steps didn’t. So, I decided to find a way to do it and then document it.</blockquote><p>If you want to just setup CI/CD using your master branch, follow Method 1, but if you want to setup CI/CD using any other branch, use Method 2.</p><h3>Method 1</h3><ol><li>Create a new Web App in the Azure portal</li></ol><ul><li>Click on <strong>Create a resource</strong> in the menu on the left</li><li>Click on <strong>Web App</strong></li><li>Enter a valid <strong>App name</strong></li><li>Select your <strong>Subscription</strong></li><li>Select your <strong>Resource Group</strong></li><li>Select your <strong>App Service Plan/Location</strong></li><li>Click on <strong>Create</strong></li></ul><p>2. Download the Publish profile for your application from the Azure portal</p><ul><li>Click on <strong>Overview </strong>in the menu on the left</li><li>Click on <strong>Get publish profile</strong></li><li>Open the publish profile using a text editor</li><li>Copy the <strong>userName</strong> and <strong>userPWD </strong>from the<strong> publish profile</strong></li></ul><p>3. Setup deployment credentials</p><ul><li>Click on <strong>Deployment credentials</strong></li><li>Enter a username in the <strong>FTP/deployment username</strong> field</li><li>Enter a password in the <strong>password</strong> field</li><li>Retype your pass in the <strong>Confirm password</strong> field</li><li>Click on<strong> Ok</strong></li></ul><p>4. Add the deployment process in the Azure project menu on the Azure portal:</p><ul><li>Click on <strong>Deployment Options</strong></li><li>Choose the source <strong>Local Git Repository</strong></li><li>Click on<strong> Ok</strong></li></ul><p>5. Generate a SSH key for your web app</p><ul><li>Type the following in your browser:</li></ul><pre>https://&lt;app_name&gt;.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1</pre><ul><li>Copy the SSH key</li></ul><p>6. Add the SSH key as a Deploy Key for your GitHub repository</p><ul><li>Go to the project settings in Github Enterprise</li><li>Click on <strong>Deploy keys </strong>in the menu on the left</li><li>Click on <strong>Add deploy key </strong>in the menu on the left</li><li>Enter a significant title in the <strong>Title</strong> text field</li><li>Paste the SSH key in the <strong>Key</strong> text field</li></ul><p>7. Add a webhook to your Github Enterprise repository</p><ul><li>Go to the project settings in Github Enterprise</li><li>Click on <strong>Hooks </strong>in the menu on the left</li><li>Click on <strong>Add webhook</strong></li><li>Set the <strong>Payload URL</strong> to the following using the <strong>userName</strong> and <strong>userPWD </strong>from the<strong> </strong>publish profile:</li></ul><pre>https://&lt;$userName&gt;:&lt;userPWD&gt;@&lt;app_name&gt;.scm.azurewebsites.net/deploy</pre><ul><li>Click on <strong>Add webhook</strong></li></ul><p>8. Ensure that in the root of your application you have a iisnode.yml with the following content (ensure that the node version is there in the directory):</p><pre>nodeProcessCommandLine: “D:\Program Files (x86)\nodejs\8.9.0\node.exe”</pre><p>9. Ensure that in the root of your application, you have a webpack.config file, with the following contents:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; <br>&lt;configuration&gt;<br>&lt;system.webServer&gt; </pre><pre>&lt;webSocket enabled=&quot;false&quot; /&gt; </pre><pre>&lt;handlers&gt; <br>     &lt;add name=&quot;iisnode&quot; path=&quot;server.js&quot; verb=&quot;*&quot; modules=&quot;iisnode&quot;/&gt;<br>&lt;/handlers&gt; </pre><pre>&lt;rewrite&gt; <br>&lt;rules&gt; </pre><pre>&lt;rule name=&quot;NodeInspector&quot; patternSyntax=&quot;ECMAScript&quot; stopProcessing=&quot;true&quot;&gt; <br>     &lt;match url=&quot;^server.js\/debug[\/]?&quot; /&gt; <br>&lt;/rule&gt; </pre><pre>&lt;rule name=&quot;StaticContent&quot;&gt; <br>     &lt;action type=&quot;Rewrite&quot; url=&quot;public{REQUEST_URI}&quot;/&gt; <br>&lt;/rule&gt; </pre><pre>&lt;rule name=&quot;DynamicContent&quot;&gt; &lt;conditions&gt; &lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;True&quot;/&gt; <br>     &lt;/conditions&gt; &lt;action type=&quot;Rewrite&quot; url=&quot;server.js&quot;/&gt; <br>&lt;/rule&gt;</pre><pre>&lt;/rules&gt; <br>&lt;/rewrite&gt; </pre><pre>&lt;security&gt; <br>     &lt;requestFiltering&gt; &lt;hiddenSegments&gt; &lt;remove segment=&quot;bin&quot;/&gt; <br>     &lt;/hiddenSegments&gt; &lt;/requestFiltering&gt; <br>&lt;/security&gt; </pre><pre>&lt;httpErrors existingResponse=&quot;PassThrough&quot; /&gt; </pre><pre>&lt;iisnode node_env=&quot;production&quot; /&gt;</pre><pre>&lt;/system.webServer&gt; <br>&lt;/configuration&gt;</pre><p>10. Ensure that your server.js file is in the root of your application</p><p>11. Ensure that in your package.json file, you have the following content (the node and npm version should be relative to what you are using):</p><pre>“engines”: { “node”: “&gt;=6.13.1”, “npm”: “&gt;=3.10.10” }</pre><p>12. Ensure that the node version of your app in Azure is the same as the version you selected in step 8:</p><ul><li>Click on <strong>Application settings</strong> in the menu on the left</li><li>In the <strong>Application settings</strong> sections, enter the value you used in step 8</li><li>Click on <strong>Save</strong></li></ul><p>13. Restart the application</p><ul><li>Click on <strong>Overview </strong>in the menu on the left</li><li>Click on <strong>Restart</strong></li></ul><p>14. Testing to see if your push to the master branch gets pushed to Azure</p><ul><li>Do a push to the master branch using git</li><li>Go to the <strong>Azure portal</strong></li><li>Click on <strong>Deployment options</strong> in the menu on the left</li><li>You should see a successful deployment</li></ul><h3>Method 2</h3><ol><li>Create a new Web App in the Azure portal</li></ol><ul><li>Click on <strong>Create a resource</strong> in the menu on the left</li><li>Click on <strong>Web App</strong></li><li>Enter a valid <strong>App name</strong></li><li>Select your <strong>Subscription</strong></li><li>Select your <strong>Resource Group</strong></li><li>Select your <strong>App Service Plan/Location</strong></li><li>Click on <strong>Create</strong></li></ul><p>2. Copy the Deployment Trigger URL</p><ul><li>Go to the Azure portal</li><li>Click on <strong>Properties</strong> from the project menu on the left</li><li>Copy the <strong>DEPLOYMENT TRIGGER URL</strong></li></ul><p>3. Add a webhook to your Github Enterprise repository</p><ul><li>Go to the project settings in Github Enterprise</li><li>Click on <strong>Hooks </strong>in the menu on the left</li><li>Click on <strong>Add webhook</strong></li><li>Set the <strong>Payload URL</strong> to the <strong>DEPLOYMENT TRIGGER URL</strong></li><li>Click on <strong>Add webhook</strong></li></ul><p>4. Generate GitHub Access Token</p><ul><li>Go to your Github Account</li><li>Go to settings (In the upper-right corner, click your profile photo, then click Settings)</li><li>In the left sidebar, click on Developer settings</li><li>In the left sidebar, click on Personal access tokens</li><li>Click on Generate new token</li><li>Select the following scopes:</li></ul><pre>Repo<br>admin:pre_receive_hook</pre><ul><li>Click on <strong>Generate token</strong></li><li>Copy the token</li></ul><p>5. Setup deployment credentials</p><ul><li>Click on <strong>Deployment credentials</strong></li><li>Enter a username in the <strong>FTP/deployment username</strong> field</li><li>Enter a password in the <strong>password</strong> field</li><li>Retype your pass in the <strong>Confirm password</strong> field</li><li>Click on<strong> Ok</strong></li></ul><p>6. Add the deployment process in the Azure project menu on the Azure portal:</p><ul><li>Click on <strong>Deployment Options</strong></li><li>Choose the source<strong> External Repository</strong></li><li>Now you have to setup your Repository URL. The github_access_token is the access token you got in Step 4 and enterprise_name is your enterpise gitHub domain name. For the <strong>Repository URL</strong>, enter following items:</li></ul><pre>https://&lt;github_access_token&gt;:x-oauth-basic@github.&lt;enterprise_name&gt;.com/&lt;repo_name_from_root&gt;</pre><ul><li>Enter the branch name in the <strong>Branch</strong> field that you want to activate the webhook when you push code to this repo</li><li>Click on<strong> Ok</strong></li></ul><p>7. Ensure that in the root of your application you have a iisnode.yml with the following content (ensure that the node version is there in the directory):</p><pre>nodeProcessCommandLine: “D:\Program Files (x86)\nodejs\8.9.0\node.exe”</pre><p>8. Ensure that in the root of your application, you have a webpack.config file, with the following contents:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; <br>&lt;configuration&gt;<br>&lt;system.webServer&gt;</pre><pre>&lt;webSocket enabled=&quot;false&quot; /&gt;</pre><pre>&lt;handlers&gt; <br>     &lt;add name=&quot;iisnode&quot; path=&quot;server.js&quot; verb=&quot;*&quot; modules=&quot;iisnode&quot;/&gt;<br>&lt;/handlers&gt;</pre><pre>&lt;rewrite&gt; <br>&lt;rules&gt;</pre><pre>&lt;rule name=&quot;NodeInspector&quot; patternSyntax=&quot;ECMAScript&quot; stopProcessing=&quot;true&quot;&gt; <br>     &lt;match url=&quot;^server.js\/debug[\/]?&quot; /&gt; <br>&lt;/rule&gt;</pre><pre>&lt;rule name=&quot;StaticContent&quot;&gt; <br>     &lt;action type=&quot;Rewrite&quot; url=&quot;public{REQUEST_URI}&quot;/&gt; <br>&lt;/rule&gt;</pre><pre>&lt;rule name=&quot;DynamicContent&quot;&gt; &lt;conditions&gt; &lt;add input=&quot;{REQUEST_FILENAME}&quot; matchType=&quot;IsFile&quot; negate=&quot;True&quot;/&gt; <br>     &lt;/conditions&gt; &lt;action type=&quot;Rewrite&quot; url=&quot;server.js&quot;/&gt; <br>&lt;/rule&gt;</pre><pre>&lt;/rules&gt; <br>&lt;/rewrite&gt;</pre><pre>&lt;security&gt; <br>     &lt;requestFiltering&gt; &lt;hiddenSegments&gt; &lt;remove segment=&quot;bin&quot;/&gt; <br>     &lt;/hiddenSegments&gt; &lt;/requestFiltering&gt; <br>&lt;/security&gt;</pre><pre>&lt;httpErrors existingResponse=&quot;PassThrough&quot; /&gt;</pre><pre>&lt;iisnode node_env=&quot;production&quot; /&gt;</pre><pre>&lt;/system.webServer&gt; <br>&lt;/configuration&gt;</pre><p>9. Ensure that your server.js file is in the root of your application</p><p>10. Ensure that in your package.json file, you have the following content (the node and npm version should be relative to what you are using):</p><pre>“engines”: { “node”: “&gt;=6.13.1”, “npm”: “&gt;=3.10.10” }</pre><p>11. Ensure that the node version of your app in Azure is the same as the version you selected in step 8:</p><ul><li>Click on <strong>Application settings</strong> in the menu on the left</li><li>In the <strong>Application settings</strong> sections, enter the value you used in step 8</li><li>Click on <strong>Save</strong></li></ul><p>12. Restart the application</p><ul><li>Click on <strong>Overview </strong>in the menu on the left</li><li>Click on <strong>Restart</strong></li></ul><p>13. Testing to see if your push to the master branch gets pushed to Azure</p><ul><li>Do a push to the master branch using git</li><li>Go to the <strong>Azure portal</strong></li><li>Click on <strong>Deployment options</strong> in the menu on the left</li><li>You should see a successful deployment</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fbaa6a51839" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>