<?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>Forem: Sunil Kumar Samanta</title>
    <description>The latest articles on Forem by Sunil Kumar Samanta (@sunilksamanta).</description>
    <link>https://forem.com/sunilksamanta</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%2F123014%2Fd0787b7e-a1fc-44c9-806b-0831469f1bc9.jpeg</url>
      <title>Forem: Sunil Kumar Samanta</title>
      <link>https://forem.com/sunilksamanta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sunilksamanta"/>
    <language>en</language>
    <item>
      <title>Basics of Serving Static Sites from a Server</title>
      <dc:creator>Sunil Kumar Samanta</dc:creator>
      <pubDate>Sun, 02 Apr 2023 17:50:57 +0000</pubDate>
      <link>https://forem.com/sunilksamanta/basics-of-serving-static-sites-from-a-server-382b</link>
      <guid>https://forem.com/sunilksamanta/basics-of-serving-static-sites-from-a-server-382b</guid>
      <description>&lt;p&gt;As a frontend developer, you may be excited about deploying your projects through various static deployment services like Vercel, GitHub Pages, Netlify, and more. While these services are excellent options for getting your static site online quickly, it's important to understand the basics of serving static sites from a server.&lt;/p&gt;

&lt;p&gt;In this article, we'll take a closer look at the basics of serving static sites from a server, including the role of HTTP, different types of servers, and the advantages of serving static sites.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Server?&lt;/strong&gt;&lt;br&gt;
First things first, let's define what we mean by a server. In the context of web development, a server is a computer or software program that stores and delivers web content. When a user requests a webpage or other online resource, the server retrieves the content and sends it back to the user's browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Static Sites are Served from a Server&lt;/strong&gt;&lt;br&gt;
When a user requests a static site, the server simply retrieves the site's HTML, CSS, and JavaScript files and sends them back to the user's browser. Since static sites don't require server-side processing, they can be served quickly and efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Role of HTTP&lt;/strong&gt;&lt;br&gt;
HTTP (Hypertext Transfer Protocol) is the protocol used to transfer web content between a server and a user's browser. When a user requests a static site, their browser sends an HTTP request to the server, which responds with an HTTP response containing the site's files. The files are then rendered in the user's browser, creating the final webpage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Servers&lt;/strong&gt;&lt;br&gt;
There are many different types of servers that can be used to serve static sites. Web servers like Apache and Nginx are popular choices, as are cloud services like AWS and Google Cloud. In addition, many static site generators like Jekyll and Hugo include built-in servers that can be used for development and testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Serving Static Sites&lt;/strong&gt;&lt;br&gt;
Serving static sites from a server offers several advantages for frontend developers. First and foremost, static sites can be served quickly and efficiently, resulting in faster page load times for users. In addition, since static sites don't require server-side processing, server costs are typically lower than with dynamic sites. Finally, serving static sites can also reduce security risks, since there is no server-side code that can be exploited by attackers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In conclusion, while static deployment services are great for quickly getting your static site online, understanding how static sites are served from a server can help you optimize your site for speed, efficiency, and security. By choosing a server option that works best for your needs, you can provide the best possible experience for your users. So the next time you deploy a static site, remember to take a moment to appreciate the powerful yet simple process that allows your site to be served to users around the world.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>frontend</category>
      <category>react</category>
      <category>angular</category>
    </item>
    <item>
      <title>CalmAPI - A Production ready REST API generator using NodeJS &amp; MongoDB</title>
      <dc:creator>Sunil Kumar Samanta</dc:creator>
      <pubDate>Sun, 09 May 2021 03:43:47 +0000</pubDate>
      <link>https://forem.com/sunilksamanta/calmapi-a-production-ready-rest-api-generator-using-nodejs-mongodb-pd9</link>
      <guid>https://forem.com/sunilksamanta/calmapi-a-production-ready-rest-api-generator-using-nodejs-mongodb-pd9</guid>
      <description>&lt;p&gt;Based on my &lt;a href="https://dev.to/sunilksamanta/rest-api-structure-using-nodejs-mongodb-mongoose-2hka"&gt;previous&lt;/a&gt; NodeJS MongoDB starter package, Here is a Production ready Modular REST API Generator using NodeJS &amp;amp; MongoDB.&lt;br&gt;
&lt;a href="https://badge.fury.io/js/calmapi" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbadge.fury.io%2Fjs%2Fcalmapi.svg" alt="npm version"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  INSTALLATION
&lt;/h3&gt;

&lt;p&gt;Install by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g calmapi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then run inside your workspace directory&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;calmapi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And follow the easy steps.&lt;/p&gt;
&lt;h3&gt;
  
  
  FEATURES
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Production ready - Controller, Model &amp;amp; Service oriented architecture&lt;/li&gt;
&lt;li&gt;Modules with automated Routing (Nested Route support)&lt;/li&gt;
&lt;li&gt;Built-in Authentication Module with JWT &amp;amp; DB Store authentication&lt;/li&gt;
&lt;li&gt;Built-in User Module&lt;/li&gt;
&lt;li&gt;Build-in CRUD operations for modules with pagination, filters, sorters&lt;/li&gt;
&lt;li&gt;Sample Post Module (CRUD Operation Example)&lt;/li&gt;
&lt;li&gt;CRUD Module generation command line support.[Alpha]&lt;/li&gt;
&lt;li&gt;No Hidden sh*ts in your node_modules. Completely free to customize&lt;/li&gt;
&lt;li&gt;Prebuilt CRUD operation classes for Controller &amp;amp; Service&lt;/li&gt;
&lt;li&gt;DTO Support( Data transfer Object)&lt;/li&gt;
&lt;li&gt;Eslint rules enabled&lt;/li&gt;
&lt;li&gt;.env support&lt;/li&gt;
&lt;li&gt;And many more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the &lt;a href="https://github.com/sunilksamanta/calmapi" rel="noopener noreferrer"&gt;github repo&lt;/a&gt; &lt;br&gt;
&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/sunilksamanta" rel="noopener noreferrer"&gt;
        sunilksamanta
      &lt;/a&gt; / &lt;a href="https://github.com/sunilksamanta/calmapi" rel="noopener noreferrer"&gt;
        calmapi
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Production ready Modular REST API Generator using NodeJS &amp;amp; MongoDB
    &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;Calm API&lt;/h1&gt;
&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Production ready Modular REST API generator using NodeJS &amp;amp; MongoDB&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://repository-images.githubusercontent.com/352502404/d0e11c00-dce4-11eb-80de-9959e403a244"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frepository-images.githubusercontent.com%2F352502404%2Fd0e11c00-dce4-11eb-80de-9959e403a244" alt="Calm API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://badge.fury.io/js/calmapi" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c61a00a21eae30391e90798431e797ad284b8928fdd455428be3542e6ac068a7/68747470733a2f2f62616467652e667572792e696f2f6a732f63616c6d6170692e737667" alt="npm version"&gt;&lt;/a&gt;
&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/5e64db2c730e6aa92c570709bf7ed4d972dc1e2ec9c21d77aa4a19d0621e24d6/68747470733a2f2f696d672e736869656c64732e696f2f64617669642f73756e696c6b73616d616e74612f63616c6d617069"&gt;&lt;img src="https://camo.githubusercontent.com/5e64db2c730e6aa92c570709bf7ed4d972dc1e2ec9c21d77aa4a19d0621e24d6/68747470733a2f2f696d672e736869656c64732e696f2f64617669642f73756e696c6b73616d616e74612f63616c6d617069" alt="David"&gt;&lt;/a&gt;
&lt;a href="https://deepscan.io/dashboard#view=project&amp;amp;tid=12352&amp;amp;pid=18169&amp;amp;bid=439384" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/3128eccee406845c948ac9ebebbacf86a2467bb21cc2dec1bfdce8ed03aec569/68747470733a2f2f646565707363616e2e696f2f6170692f7465616d732f31323335322f70726f6a656374732f31383136392f6272616e636865732f3433393338342f62616467652f67726164652e737667" alt="DeepScan grade"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;INSTALLATION&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;Install by running&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npm i -g calmapi&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then run inside your workspace directory&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And follow the easy steps.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;MODULE GENERATION&lt;/h3&gt;

&lt;/div&gt;

&lt;p&gt;Generate CalmAPI CRUD Module just by running the following inside project's root.&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module product&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Valid Module generation commands.&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module product&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module products&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module productMeta&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module ProductMeta&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module product-meta&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Generate Module name without pluralize&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;calmapi generate module test-series --force&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;FEATURES&lt;/h3&gt;

&lt;/div&gt;


&lt;ul&gt;

&lt;li&gt;Production ready - Controller, Model &amp;amp; Service oriented architecture&lt;/li&gt;

&lt;li&gt;Modules with automated Routing (Nested Route support)&lt;/li&gt;

&lt;li&gt;Built-in Authentication Module with JWT &amp;amp; DB Store authentication&lt;/li&gt;

&lt;li&gt;Built-in User Module&lt;/li&gt;

&lt;li&gt;Built-in Media Module for file upload [AWS S3 Support]&lt;/li&gt;

&lt;li&gt;Build-in CRUD operations for modules with pagination, filters, sorters&lt;/li&gt;

&lt;li&gt;Sample Post Module (CRUD Operation Example)&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;CRUD Module generation command line support.&lt;/strong&gt;&lt;/li&gt;

&lt;li&gt;No Hidden sh*ts in your node_modules. Completely…&lt;/li&gt;

&lt;/ul&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sunilksamanta/calmapi" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;em&gt;We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: Reporting a bug, Documentation, Discussing the current state of the code, Submitting a fix or Proposing new features.&lt;/em&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>restapi</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Self Hosted Open Source Solutions List</title>
      <dc:creator>Sunil Kumar Samanta</dc:creator>
      <pubDate>Fri, 09 Oct 2020 03:26:03 +0000</pubDate>
      <link>https://forem.com/sunilksamanta/self-hosted-open-source-solutions-list-53p4</link>
      <guid>https://forem.com/sunilksamanta/self-hosted-open-source-solutions-list-53p4</guid>
      <description>&lt;h3&gt;
  
  
  Here is the list for Self Hosted alternative of some SAAS.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Blogging / CMS:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wordpress.org/download/"&gt;Wordpress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ghost.org/docs/setup/"&gt;Ghost&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Chat [With API]
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://rocket.chat/install/"&gt;Rocket chat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://sdelements.github.io/lets-chat/"&gt;Lets Chat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mattermost.com/download/"&gt;Mattermost Server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Video Conference [With API]
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.bigbluebutton.org/2.2/install.html"&gt;BigBlueButton&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jitsi.org/downloads/"&gt;Jitsi Meet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Document Database
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mongodb.com/try/download/community"&gt;MongoDB Community Server (Most popular document DB)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rethinkdb.com/"&gt;RethinkDB (Realtime DB)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list will update time to time. Please comment any new category or any self hostel tool. I'll update in this.&lt;/p&gt;

&lt;p&gt;Hope this will help some people. &lt;/p&gt;

</description>
      <category>opensource</category>
      <category>mongodb</category>
      <category>chat</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>If you don't like Mondays, Its time to change!</title>
      <dc:creator>Sunil Kumar Samanta</dc:creator>
      <pubDate>Fri, 09 Oct 2020 01:44:26 +0000</pubDate>
      <link>https://forem.com/sunilksamanta/if-you-don-t-like-mondays-its-time-to-change-423a</link>
      <guid>https://forem.com/sunilksamanta/if-you-don-t-like-mondays-its-time-to-change-423a</guid>
      <description>&lt;p&gt;If you don't like the Mondays, then you should probably change your job. Because if Mondays are always been your headache, you won't be able to work longer where you're working currently. Not just that, you'll loose interest in everything. That'll impact your social life, family. So if possible go for a job where you can discover yourself. You can improve yourself. &lt;/p&gt;

&lt;p&gt;Your thoughts? &lt;/p&gt;

</description>
      <category>motivation</category>
      <category>developer</category>
      <category>jokes</category>
    </item>
    <item>
      <title>REST API Structure using NodeJS MongoDB (Mongoose)</title>
      <dc:creator>Sunil Kumar Samanta</dc:creator>
      <pubDate>Fri, 02 Oct 2020 15:31:38 +0000</pubDate>
      <link>https://forem.com/sunilksamanta/rest-api-structure-using-nodejs-mongodb-mongoose-2hka</link>
      <guid>https://forem.com/sunilksamanta/rest-api-structure-using-nodejs-mongodb-mongoose-2hka</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzxvx4pk4tdlqyk1x2a4c.png" class="article-body-image-wrapper"&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-uploads.s3.amazonaws.com%2Fi%2Fzxvx4pk4tdlqyk1x2a4c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  [UPDATE 2] New modified more robust structure with Generation Tool. Check out here &lt;a href="https://dev.to/sunilksamanta/calmapi-a-production-ready-rest-api-generator-using-nodejs-mongodb-pd9"&gt;https://dev.to/sunilksamanta/calmapi-a-production-ready-rest-api-generator-using-nodejs-mongodb-pd9&lt;/a&gt;
&lt;/h3&gt;

&lt;h3&gt;
  
  
  [UPDATE] There are structure improvements and addon features. Please follow the git repo for updated structure.
&lt;/h3&gt;

&lt;p&gt;For each and every project I usually prefer using different architectures. It not just helps me explore new techniques but helps me make the next project better than before by applying the best of them and leave the worst.&lt;/p&gt;

&lt;p&gt;Few months ago I found &lt;a href="https://dev.to/pacheco/designing-a-better-architecture-for-a-node-js-api-24d"&gt;this article&lt;/a&gt; interesting. With writing a very minimum line of code you’ll get an API ready. I followed this structure and created my own with some customization and added basic modules and made it REST ready out of the box. The project features —&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Controller, Model &amp;amp; Service oriented architecture&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Auth with JWT &amp;amp; Db Store&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Module&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Post Module&lt;/strong&gt; (Sample CRUD)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Media Upload&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Centralized Http Response&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Error Handler&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.env support&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi Environment config setup&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Autobind Methods&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;If you’re too lazy to read further, here is the &lt;a href="https://github.com/sunilksamanta/node-mongoose-setup" rel="noopener noreferrer"&gt;github repo&lt;/a&gt; for full project.&lt;/em&gt;&lt;/strong&gt;&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/sunilksamanta" rel="noopener noreferrer"&gt;
        sunilksamanta
      &lt;/a&gt; / &lt;a href="https://github.com/sunilksamanta/node-mongoose-setup" rel="noopener noreferrer"&gt;
        node-mongoose-setup
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Nodejs MongoDB REST API Sarter
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/8095d799edbf36d814f74fd6053afe36d95eb100a7fbdc59384b240a61a6caeb/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f692f7a78767834706b3474646c71796b3178326134632e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/8095d799edbf36d814f74fd6053afe36d95eb100a7fbdc59384b240a61a6caeb/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f692f7a78767834706b3474646c71796b3178326134632e706e67" alt="REST API Setup Nodejs MongoDB"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/sunilksamanta/node-mongoose-setup/workflows/Node.js%20CI/badge.svg"&gt;&lt;img src="https://github.com/sunilksamanta/node-mongoose-setup/workflows/Node.js%20CI/badge.svg" alt="example workflow name"&gt;&lt;/a&gt;
&lt;a href="https://travis-ci.org/sunilksamanta/node-mongoose-setup" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c641d05c8098ac1782886a8c0be02b9077e5ad2153548eb440a18a6281bb37c5/68747470733a2f2f7472617669732d63692e6f72672f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d73657475702e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;a href="https://codeclimate.com/github/sunilksamanta/node-mongoose-setup/maintainability" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f49a6ad0fa55ebecfc78c23dd338da11a9fc2e7f50d5efd73e502664baa96266/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32356438636363653732333061643565623563332f6d61696e7461696e6162696c697479" alt="Maintainability"&gt;&lt;/a&gt;
&lt;a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fsunilksamanta%2Fnode-mongoose-setup?ref=badge_shield" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/770e8d1fd34535ec96528ad39e1172f3bb141a7cdb88bb025fca8a1c7ef2c636/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d25324673756e696c6b73616d616e74612532466e6f64652d6d6f6e676f6f73652d73657475702e7376673f747970653d736869656c64" alt="FOSSA Status"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setupcontributing.md" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/88482ebfc5e3e4f2d667148ab6a3eb55948789f1dba71dfa0eb2e05afe02958c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265" alt="PRs Welcome"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setup/issues" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/fd23a65670e02b428d9c50916d2f0574934620fe915629052da270c94bcc247a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d7365747570" alt="GitHub issues"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setup/stargazers" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/eb863ba437691b4c0cebdcbae8d91b11c96fd8b5952fe8d6254b8287e785fc83/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d7365747570" alt="GitHub stars"&gt;&lt;/a&gt;
&lt;a href="https://twitter.com/intent/tweet?text=Wow:&amp;amp;url=https%3A%2F%2Fgithub.com%2Fsunilksamanta%2Fnode-mongoose-setup" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/9637a4b5ea9ab537d3b1f819ff32c3506b2846e5de607f90c0b238fa95cab089/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c3f7374796c653d666c61742d7371756172652675726c3d68747470732533412532462532466769746875622e636f6d25324673756e696c6b73616d616e74612532466e6f64652d6d6f6e676f6f73652d7365747570" alt="Twitter"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Installation&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Setup is super easy. Clone the repository -&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;git clone https://github.com/sunilksamanta/node-mongoose-setup
&lt;span class="pl-c1"&gt;cd&lt;/span&gt; node-mongoose-setup
npm install&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Create an &lt;code&gt;.env&lt;/code&gt; file at the root of your project with the following.&lt;/p&gt;
&lt;div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-v"&gt;MONGO_URL&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_MONGO_URL&lt;/span&gt;
&lt;span class="pl-v"&gt;PORT&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;5000[YOUR_DESIRED_PORT]&lt;/span&gt;
&lt;span class="pl-v"&gt;NODE_ENV&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_APP_ENVIRONMENT[production/development]&lt;/span&gt;
&lt;span class="pl-v"&gt;JWT_SECRET&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_JWT_SECRET_STRING&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;An example file &lt;code&gt;.env.example&lt;/code&gt; is included.&lt;/p&gt;
&lt;p&gt;Your project is ready. Now start the project.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npm start&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Go to &lt;code&gt;http://localhost:5000&lt;/code&gt;. You should see a default welcome page.&lt;/p&gt;
&lt;p&gt;Your API base path is &lt;code&gt;http://localhost:5000/api&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First create some accounts to get started with the authentication.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Authentication&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;JWT authentication is added in this project. User model is defined in models/User.js
For Register, Login, Logout use these urls —&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;    [POST] api/auth/register
    [POST] api/auth/login
    [GET] api/auth/logout
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features&lt;/h2&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Controller, Model &amp;amp; Service oriented architecture&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Auth with JWT &amp;amp; Db Store&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Async/Await support&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Module&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Post Module&lt;/strong&gt; (Sample CRUD)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Media Upload&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Centralized Http Response&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Error Handler&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;.env support&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi Environment config setup&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Autobind Methods&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Built&lt;/strong&gt;…&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sunilksamanta/node-mongoose-setup" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Lets dig into the Matrix..&lt;/p&gt;

&lt;h2&gt;
  
  
  What we’re using?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;NodeJS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MongoDB (Mongoose ODM)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Directory Structure of the Project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       ├─ .env
       ├─ .gitignore
       ├─ config
       │  ├─ config.js
       │  ├─ database.js
       │  ├─ routes.js
       │  └─ server.js
       ├─ index.js
       ├─ package.json
       └─ src
          ├─ controllers
          │  ├─ AuthController.js
          │  ├─ Controller.js
          │  ├─ MediaController.js
          │  └─ PostController.js
          ├─ helpers
          │  ├─ HttpError.js
          │  ├─ HttpResponse.js
          │  └─ Utility.js
          ├─ models
          │  ├─ Auth.js
          │  ├─ Media.js
          │  ├─ Post.js
          │  └─ User.js
          ├─ routes
          │  ├─ auth.js
          │  ├─ index.js
          │  ├─ media.js
          │  └─ post.js
          └─ services
             ├─ AuthService.js
             ├─ MediaService.js
             ├─ PostService.js
             ├─ Service.js
             └─ UserService.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Lets talk about the structure
&lt;/h2&gt;

&lt;p&gt;If you’ve already read the article where I found the struture then you’ve already understood what the structure does. If not please follow &lt;strong&gt;&lt;a href="https://dev.to/pacheco/designing-a-better-architecture-for-a-node-js-api-24d"&gt;this link&lt;/a&gt;&lt;/strong&gt; for better understanding of the basics of this architecture.&lt;/p&gt;

&lt;p&gt;We have 2 base classes — One for Controller and another for Service.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Controller.js&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This base controller have the basic CRUD operations. To create a new controller just extend this base Controller class.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Service.js&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the base Service class which includes the database operations. If you want to change the default behaviour of the services you can update this file.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  How to Create new CRUD Module?
&lt;/h2&gt;

&lt;p&gt;If you want to create a new Module say Post. Then you’ll have to create 4 basic files. One Controller, one Service, one Model and one route file. And add the new route in routes/index.js with desired url.&lt;br&gt;
There is a “Post” CRUD module included in this project for example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    controllers/PostController.js
    models/Post.js
    services/PostService.js
    routes/post.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Overriding Base class method
&lt;/h2&gt;

&lt;p&gt;As an example if you see in the media Controller — the default delete method is overriden by its own class method as we have to delete the file from the file system also. So the overriden method is like bellow —&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async delete(req, res, next) {
  const { id } = req.params;
  try {
      const response = await this.service.delete(id);
      // File Unlinking..
      if (response.data.path) {
          console.log("unlink item", response.data.path);
          fs.unlink(response.data.path, function (err) {
              if (err) {
                  console.log("error deleting file");
                  throw err;
              }
              console.log("File deleted!");
          });
      }
      return res.status(response.statusCode).json(response);
  }
  catch (e) {
      next(e);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Authentication
&lt;/h2&gt;

&lt;p&gt;JWT authentication is added in this project. User model is defined in models/User.js. &lt;br&gt;
For Register, Login, Logout use these urls —&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    [POST] api/auth/register
    [POST] api/auth/login
    [GET] api/auth/logout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Thats all for now.. If you need any help, I’ll love to do so.&lt;br&gt;
Here is once again the git repo..&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/sunilksamanta" rel="noopener noreferrer"&gt;
        sunilksamanta
      &lt;/a&gt; / &lt;a href="https://github.com/sunilksamanta/node-mongoose-setup" rel="noopener noreferrer"&gt;
        node-mongoose-setup
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Nodejs MongoDB REST API Sarter
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/8095d799edbf36d814f74fd6053afe36d95eb100a7fbdc59384b240a61a6caeb/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f692f7a78767834706b3474646c71796b3178326134632e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/8095d799edbf36d814f74fd6053afe36d95eb100a7fbdc59384b240a61a6caeb/68747470733a2f2f6465762d746f2d75706c6f6164732e73332e616d617a6f6e6177732e636f6d2f692f7a78767834706b3474646c71796b3178326134632e706e67" alt="REST API Setup Nodejs MongoDB"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/sunilksamanta/node-mongoose-setup/workflows/Node.js%20CI/badge.svg"&gt;&lt;img src="https://github.com/sunilksamanta/node-mongoose-setup/workflows/Node.js%20CI/badge.svg" alt="example workflow name"&gt;&lt;/a&gt;
&lt;a href="https://travis-ci.org/sunilksamanta/node-mongoose-setup" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/c641d05c8098ac1782886a8c0be02b9077e5ad2153548eb440a18a6281bb37c5/68747470733a2f2f7472617669732d63692e6f72672f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d73657475702e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;a href="https://codeclimate.com/github/sunilksamanta/node-mongoose-setup/maintainability" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/f49a6ad0fa55ebecfc78c23dd338da11a9fc2e7f50d5efd73e502664baa96266/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32356438636363653732333061643565623563332f6d61696e7461696e6162696c697479" alt="Maintainability"&gt;&lt;/a&gt;
&lt;a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fsunilksamanta%2Fnode-mongoose-setup?ref=badge_shield" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/770e8d1fd34535ec96528ad39e1172f3bb141a7cdb88bb025fca8a1c7ef2c636/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d25324673756e696c6b73616d616e74612532466e6f64652d6d6f6e676f6f73652d73657475702e7376673f747970653d736869656c64" alt="FOSSA Status"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setupcontributing.md" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/88482ebfc5e3e4f2d667148ab6a3eb55948789f1dba71dfa0eb2e05afe02958c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265" alt="PRs Welcome"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setup/issues" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/fd23a65670e02b428d9c50916d2f0574934620fe915629052da270c94bcc247a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d7365747570" alt="GitHub issues"&gt;&lt;/a&gt;
&lt;a href="https://github.com/sunilksamanta/node-mongoose-setup/stargazers" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/eb863ba437691b4c0cebdcbae8d91b11c96fd8b5952fe8d6254b8287e785fc83/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f73756e696c6b73616d616e74612f6e6f64652d6d6f6e676f6f73652d7365747570" alt="GitHub stars"&gt;&lt;/a&gt;
&lt;a href="https://twitter.com/intent/tweet?text=Wow:&amp;amp;url=https%3A%2F%2Fgithub.com%2Fsunilksamanta%2Fnode-mongoose-setup" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/9637a4b5ea9ab537d3b1f819ff32c3506b2846e5de607f90c0b238fa95cab089/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c3f7374796c653d666c61742d7371756172652675726c3d68747470732533412532462532466769746875622e636f6d25324673756e696c6b73616d616e74612532466e6f64652d6d6f6e676f6f73652d7365747570" alt="Twitter"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Installation&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;Setup is super easy. Clone the repository -&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;git clone https://github.com/sunilksamanta/node-mongoose-setup
&lt;span class="pl-c1"&gt;cd&lt;/span&gt; node-mongoose-setup
npm install&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Create an &lt;code&gt;.env&lt;/code&gt; file at the root of your project with the following.&lt;/p&gt;
&lt;div class="highlight highlight-source-dotenv notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-v"&gt;MONGO_URL&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_MONGO_URL&lt;/span&gt;
&lt;span class="pl-v"&gt;PORT&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;5000[YOUR_DESIRED_PORT]&lt;/span&gt;
&lt;span class="pl-v"&gt;NODE_ENV&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_APP_ENVIRONMENT[production/development]&lt;/span&gt;
&lt;span class="pl-v"&gt;JWT_SECRET&lt;/span&gt;&lt;span class="pl-k"&gt;=&lt;/span&gt;&lt;span class="pl-s"&gt;YOUR_JWT_SECRET_STRING&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;An example file &lt;code&gt;.env.example&lt;/code&gt; is included.&lt;/p&gt;
&lt;p&gt;Your project is ready. Now start the project.&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;npm start&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Go to &lt;code&gt;http://localhost:5000&lt;/code&gt;. You should see a default welcome page.&lt;/p&gt;
&lt;p&gt;Your API base path is &lt;code&gt;http://localhost:5000/api&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First create some accounts to get started with the authentication.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Authentication&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;JWT authentication is added in this project. User model is defined in models/User.js
For Register, Login, Logout use these urls —&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;    [POST] api/auth/register
    [POST] api/auth/login
    [GET] api/auth/logout
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features&lt;/h2&gt;

&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Controller, Model &amp;amp; Service oriented architecture&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Auth with JWT &amp;amp; Db Store&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Async/Await support&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Module&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Post Module&lt;/strong&gt; (Sample CRUD)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Media Upload&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Centralized Http Response&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Error Handler&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;.env support&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi Environment config setup&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Autobind Methods&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Built&lt;/strong&gt;…&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sunilksamanta/node-mongoose-setup" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Want to contribute?
&lt;/h2&gt;

&lt;p&gt;If you have any suggestion, feedback or you want to make this project more powerful — feel free to report issues or request a feature or suggest some changes. Fork and PR.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

&lt;p&gt;Originally published in medium -&amp;gt; &lt;a href="https://medium.com/@sunilksamanta/rest-api-architecture-using-nodejs-mongodb-mongoose-64f9021c906f" rel="noopener noreferrer"&gt;REST API Structure using NodeJS MongoDB (Mongoose)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>mongodb</category>
      <category>rest</category>
      <category>api</category>
    </item>
  </channel>
</rss>
