<?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: Md. Ashiqur Rahman</title>
    <description>The latest articles on DEV Community by Md. Ashiqur Rahman (@mdashikar).</description>
    <link>https://dev.to/mdashikar</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%2F106945%2Fd15ed706-e6f3-4375-a38c-cc5d7dc7600b.jpg</url>
      <title>DEV Community: Md. Ashiqur Rahman</title>
      <link>https://dev.to/mdashikar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mdashikar"/>
    <language>en</language>
    <item>
      <title>Getting Started with the RESTful API NodeJs Starter Template</title>
      <dc:creator>Md. Ashiqur Rahman</dc:creator>
      <pubDate>Fri, 28 Jun 2024 15:13:51 +0000</pubDate>
      <link>https://dev.to/mdashikar/getting-started-with-the-restful-api-node-starter-template-31g3</link>
      <guid>https://dev.to/mdashikar/getting-started-with-the-restful-api-node-starter-template-31g3</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Creating a RESTful API from scratch can be a daunting task, especially when you need to ensure it's production-ready with all the essential features like authentication, validation, and logging. But what if you could kickstart your project with a robust, fully-configured template? Introducing the &lt;a href="https://github.com/mdashikar/starter-template-nodejs" rel="noopener noreferrer"&gt;Node.js Starter Template&lt;/a&gt;, a comprehensive boilerplate that simplifies API development. This template leverages Node.js, Express, and Mongoose to provide a solid foundation for your next project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quick Start
&lt;/h3&gt;

&lt;p&gt;Getting started with this template is incredibly easy. You can create a new project with just one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-starter-template-nodejs &amp;lt;project-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can use npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init starter-template-nodejs &amp;lt;project-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For those who prefer manual installation, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the repository:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &lt;span class="nt"&gt;--depth&lt;/span&gt; 1 https://github.com/mdashikar/starter-template-nodejs.git
&lt;span class="nb"&gt;cd &lt;/span&gt;starter-template-nodejs
npx rimraf ./.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install the dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the environment variables:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;p&gt;This starter template comes packed with features to jumpstart your development process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MongoDB:&lt;/strong&gt; Use Mongoose for object data modeling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authentication &amp;amp; Authorization:&lt;/strong&gt; Implement JWT-based authentication and role-based access control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request Validation:&lt;/strong&gt; Utilize Joi for request data validation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensive Logging:&lt;/strong&gt; Employ Winston and Morgan for effective logging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Documentation:&lt;/strong&gt; With swagger-jsdoc and swagger-ui-express&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process Management:&lt;/strong&gt; Use PM2 for advanced production process management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment Configuration:&lt;/strong&gt; Manage environment variables with dotenv and cross-env.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Measures:&lt;/strong&gt; Enhance security with Helmet and sanitize inputs against XSS and query injection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CORS &amp;amp; Compression:&lt;/strong&gt; Enable Cross-Origin Resource Sharing and gzip compression.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Support:&lt;/strong&gt; Run your application in a Docker container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git Hooks:&lt;/strong&gt; Husky and lint-staged.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linting &amp;amp; Formatting:&lt;/strong&gt; Maintain code quality with ESLint and Prettier.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Running the Application
&lt;/h3&gt;

&lt;p&gt;To run the application locally:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;For production:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing
&lt;/h3&gt;

&lt;p&gt;This template supports extensive testing with Jest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Run all tests:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run tests in watch mode:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;test&lt;/span&gt;:watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using Docker
&lt;/h3&gt;

&lt;p&gt;You can also run the application in a Docker container:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For development:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run docker:dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For production:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run docker:prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To run tests in a Docker container:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run docker:test
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Linting and Formatting
&lt;/h3&gt;

&lt;p&gt;Ensure your code adheres to best practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Run ESLint:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run lint
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fix ESLint errors:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run lint:fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run Prettier:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fix Prettier errors:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run prettier:fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Environment Variables
&lt;/h3&gt;

&lt;p&gt;Modify the environment variables in the &lt;code&gt;.env&lt;/code&gt; file to fit your setup. Here are some defaults:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;NODE_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;development
&lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3000
&lt;span class="nv"&gt;MONGODB_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mongodb://mongodb:27017/node-boilerplate
&lt;span class="nv"&gt;JWT_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;thisisasamplesecret
&lt;span class="nv"&gt;JWT_ACCESS_EXPIRATION_MINUTES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30
&lt;span class="nv"&gt;JWT_REFRESH_EXPIRATION_DAYS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;30
&lt;span class="nv"&gt;SMTP_HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;smtp-relay.brevo.com
&lt;span class="nv"&gt;SMTP_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;587
&lt;span class="nv"&gt;SMTP_AUTH_USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;601f7f001@smtp-brevo.com
&lt;span class="nv"&gt;SMTP_AUTH_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;BRGVQs6vacTC37d5
&lt;span class="nv"&gt;MAIL_FORM&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;support@starter-template-nodejs.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The RESTful API Node Starter Template is a powerful tool for quickly building RESTful APIs using Node.js, Express, and Mongoose. With its rich set of features and well-organized project structure, it provides a solid foundation for your next project.&lt;/p&gt;

&lt;p&gt;Ready to start building? Check out the &lt;a href="https://github.com/mdashikar/starter-template-nodejs" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt; and get started today!&lt;/p&gt;

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

</description>
      <category>node</category>
      <category>express</category>
      <category>mongodb</category>
      <category>api</category>
    </item>
    <item>
      <title>What are the best vuejs framework for Native Mobile App?</title>
      <dc:creator>Md. Ashiqur Rahman</dc:creator>
      <pubDate>Tue, 16 Oct 2018 10:08:45 +0000</pubDate>
      <link>https://dev.to/mdashikar/what-are-the-best-vuejs-framework-for-native-mobile-app-3ie7</link>
      <guid>https://dev.to/mdashikar/what-are-the-best-vuejs-framework-for-native-mobile-app-3ie7</guid>
      <description>

</description>
      <category>nativeapp</category>
      <category>vue</category>
      <category>androidapp</category>
      <category>iosapp</category>
    </item>
  </channel>
</rss>
