<?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: Ahmad Joya</title>
    <description>The latest articles on DEV Community by Ahmad Joya (@ahmadjoya).</description>
    <link>https://dev.to/ahmadjoya</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%2F1061926%2F380e547e-8023-45ee-a328-bf07ac0b353f.jpeg</url>
      <title>DEV Community: Ahmad Joya</title>
      <link>https://dev.to/ahmadjoya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmadjoya"/>
    <language>en</language>
    <item>
      <title>TypeScript Express Mongoose Starter: A Comprehensive Starter Boilerplate Guide</title>
      <dc:creator>Ahmad Joya</dc:creator>
      <pubDate>Mon, 05 Jun 2023 05:20:43 +0000</pubDate>
      <link>https://dev.to/ahmadjoya/typescript-express-mongoose-starter-a-comprehensive-starter-boilerplate-guide-1n4j</link>
      <guid>https://dev.to/ahmadjoya/typescript-express-mongoose-starter-a-comprehensive-starter-boilerplate-guide-1n4j</guid>
      <description>&lt;p&gt;Are you looking to build a robust Node.js API using TypeScript, Express.js, and Mongoose? Look no further! The TypeScript Express Mongoose Starter provides a solid foundation for developing scalable and maintainable web APIs with ease. In this article, we’ll explore the features, installation process, configuration, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;p&gt;The TypeScript Express Mongoose Starter comes packed with a variety of features to accelerate your API development process. Here are some of its key features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript:&lt;/strong&gt; Enjoy the benefits of static typing, enhanced code maintainability, and better developer tooling with TypeScript.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Express.js:&lt;/strong&gt; Build powerful and flexible web APIs using the popular Express.js framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mongoose:&lt;/strong&gt; Utilize the elegant MongoDB object modeling library Mongoose for seamless integration with MongoDB databases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User Authentication:&lt;/strong&gt; Includes a pre-configured user authentication system with password hashing using bcrypt and JWT-based authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Documentation:&lt;/strong&gt; Generate API documentation effortlessly with Swagger and Swagger UI integration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Implement centralized error handling and consistent error responses across your application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment Configuration:&lt;/strong&gt; Manage your application’s configuration using environment variables with the help of the dotenv library.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linting and Formatting:&lt;/strong&gt; Maintain clean and consistent code with ESLint and Prettier pre-configured.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing with Jest:&lt;/strong&gt; Write unit tests and run them using the Jest testing framework.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Integration:&lt;/strong&gt; Easily containerize your application using Docker for simplified deployment and scalability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nginx Reverse Proxy:&lt;/strong&gt; Set up Nginx as a reverse proxy to enhance performance, security, and load balancing capabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process Management:&lt;/strong&gt; Utilize PM2 or Nodemon for process management and automatic application restarts during development and production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SWC Compiler:&lt;/strong&gt; Utilize the SWC compiler for faster TypeScript compilation and improved performance.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To create a new project using this starter template, follow these steps:&lt;/p&gt;

&lt;p&gt;Open your terminal or command prompt.&lt;br&gt;
Use the following command to scaffold the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx typescript-express-mongoose-starter &amp;lt;project-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don’t specify a project name, the default name &lt;u&gt;typescript-express-mongoose-starter&lt;/u&gt; will be used.&lt;/p&gt;

&lt;p&gt;Alternatively, you can clone the repository and install the dependencies manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/ahmadjoya/typescript-express-mongoose-starter.git
$ cd typescript-express-mongoose-starter
$ npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;Before starting the project, make sure to set up your database credentials in the .env.development.local file. This file is used for local development and should not be committed to version control. Here's an example of how the .env.development.local file should be structured:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_HOST=localhost
DB_PORT=27017
DB_DATABASE=dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to replace the values according to your specific database setup. Remember to keep this file secure and avoid committing it to version control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The TypeScript Express Mongoose Starter provides an excellent foundation for building scalable and maintainable Node.js APIs. With features like TypeScript, Express.js, Mongoose, user authentication, API documentation, and more, you can kickstart your project with confidence. Follow the installation steps and configure your database, and you’ll be ready to dive into coding.&lt;/p&gt;

&lt;p&gt;Visit the &lt;a href="https://github.com/ahmadjoya/typescript-express-mongoose-starter"&gt;GitHub repository&lt;/a&gt; or &lt;a href="https://www.npmjs.com/package/typescript-express-mongoose-starter"&gt;NPM package&lt;/a&gt; to explore the project and get started today!&lt;/p&gt;

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

</description>
      <category>typescript</category>
      <category>express</category>
      <category>mongoose</category>
      <category>docker</category>
    </item>
    <item>
      <title>The Nullish coalescing operator (??)</title>
      <dc:creator>Ahmad Joya</dc:creator>
      <pubDate>Sun, 09 Apr 2023 16:57:12 +0000</pubDate>
      <link>https://dev.to/ahmadjoya/the-nullish-coalescing-operator--186d</link>
      <guid>https://dev.to/ahmadjoya/the-nullish-coalescing-operator--186d</guid>
      <description>&lt;p&gt;The Nullish coalescing operator (??) is a new operator introduced in ECMAScript 2020 (also known as ES11). It is used to provide a default value when a variable is null or undefined.&lt;/p&gt;

&lt;p&gt;In JavaScript, when you want to set a default value for a variable that could be null or undefined, you often use the logical OR (||) operator. For example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9JU7ztQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi5xvjslby3dp54md66v.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9JU7ztQ0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vi5xvjslby3dp54md66v.PNG" alt="Image description" width="651" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, this approach has a limitation: if the variable is falsy, but not null or undefined (e.g., it could be an empty string or the number 0), the default value will still be assigned. For example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--omZok97x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rancq1wiulfndfpl80u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--omZok97x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rancq1wiulfndfpl80u.png" alt="Image description" width="651" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To solve this problem, the Nullish coalescing operator (??) was introduced. It only checks for null or undefined values, and ignores other falsy values. For example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cud9bM2x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqbg27ev198v10hwd3v4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cud9bM2x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqbg27ev198v10hwd3v4.png" alt="Image description" width="651" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this way, the Nullish coalescing operator allows you to more accurately and safely provide default values for variables that may be null or undefined&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nullish</category>
      <category>coalescing</category>
      <category>oprator</category>
    </item>
    <item>
      <title>Conventional Commit Message and Linting</title>
      <dc:creator>Ahmad Joya</dc:creator>
      <pubDate>Sun, 09 Apr 2023 16:16:06 +0000</pubDate>
      <link>https://dev.to/ahmadjoya/conventional-commit-message-and-linting-1bf7</link>
      <guid>https://dev.to/ahmadjoya/conventional-commit-message-and-linting-1bf7</guid>
      <description>&lt;p&gt;These are common commit message prefixes or types that can be used to indicate the purpose of a commit in a project's version control history. Here's what each of them typically means:&lt;/p&gt;

&lt;p&gt;✓ build: Changes related to the build system or external dependencies, such as package updates, build tool configuration changes, or CI/CD pipeline updates.&lt;br&gt;
✓ chore: Changes that do not affect the code, such as updating documentation, refactoring code comments, or making minor code changes that don't affect the functionality of the application.&lt;br&gt;
✓ ci: Changes to the continuous integration (CI) configuration files or scripts.&lt;br&gt;
✓ docs: Changes to documentation files, such as user guides, README files, or API documentation.&lt;br&gt;
✓ feat: The addition of a new feature to the application or library.&lt;br&gt;
✓ fix: The resolution of a bug or issue in the application or library.&lt;br&gt;
✓ perf: Changes related to performance optimization, such as code refactoring to improve execution speed or reduce memory usage.&lt;br&gt;
✓ refactor: Changes to the codebase that do not add new features or fix bugs, but improve the overall structure or readability of the code.&lt;br&gt;
✓ revert: A commit that undoes a previous commit.&lt;br&gt;
✓ style: Changes to the code that do not affect its functionality, but improve its readability or aesthetics, such as code formatting, indentation, or naming conventions.&lt;br&gt;
✓ test: Changes or additions to automated tests, such as unit tests, integration tests, or end-to-end tests.&lt;/p&gt;

&lt;p&gt;These commit message prefixes can help to provide context and organization in a project's version control history, making it easier to understand and track changes over time.&lt;br&gt;
Note: if you want to force these rules on commit messages, here is a commit linting lib for you. &lt;a href="https://github.com/conventional-changelog/commitlint"&gt;Commitlint&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>cleancode</category>
    </item>
  </channel>
</rss>
