<?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: Subrat kumar jena</title>
    <description>The latest articles on DEV Community by Subrat kumar jena (@subrat611).</description>
    <link>https://dev.to/subrat611</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%2F952268%2Fbe6048be-035b-49f2-be88-77a29a0247af.png</url>
      <title>DEV Community: Subrat kumar jena</title>
      <link>https://dev.to/subrat611</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/subrat611"/>
    <language>en</language>
    <item>
      <title>Express JS - part 1</title>
      <dc:creator>Subrat kumar jena</dc:creator>
      <pubDate>Sun, 23 Oct 2022 07:35:05 +0000</pubDate>
      <link>https://dev.to/subrat611/express-js-part-1-105i</link>
      <guid>https://dev.to/subrat611/express-js-part-1-105i</guid>
      <description>&lt;h2&gt;
  
  
  What is Express js?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;It is a framework for node js written over node js.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a server in &lt;strong&gt;node js&lt;/strong&gt; is very time taking as well as it is difficult to understand for beginners.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;visual representation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rhfOlsmO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gffpdybjhj8mmpwq8u0t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rhfOlsmO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gffpdybjhj8mmpwq8u0t.png" alt="lines of code node vs express" width="747" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Express js?
&lt;/h2&gt;

&lt;p&gt;Express allows developers to focus on business logic. Instead of focusing on details(routing, parsing incoming body requests).&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Express and Creating server.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;install express in your project as production dependencies.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;get required modules - in &lt;strong&gt;app.js&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const http = require('http)
const express = require('express')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;set the app with the express()
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const app = express()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create server by calling createServer method and pass &lt;strong&gt;app&lt;/strong&gt; as callback handler
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const server = http.createServer(app)
server.listen(3000)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;run the &lt;strong&gt;nodemon server&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;npm start&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If nodemon not installed follow these steps&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;make changes to the &lt;strong&gt;package.json&lt;/strong&gt; file - in &lt;strong&gt;script&lt;/strong&gt;, add the main js file where the server is initialized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;in my case main file is &lt;strong&gt;app.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "start": "node app.js",
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1"
  },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>node</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
