TEMPLATE NESTJS

screenshot of TEMPLATE NESTJS

This project is my template using NestJS. It's a server entirely configured with eslint, prettier and few routes already defined. The project also has already a system of authentication using Passport.js configured.

Overview:

This product is a template for Nest.js, a framework for building scalable and flexible applications. The template aims to provide a structured and well-designed codebase that is easy to review and scale. It includes various features and tools such as Docker-compose environments, a reverse proxy, refresh token functionality, Sonar for code quality checks, initialization of MongoDB with pre-defined data, in-memory database support, absolute path configuration, typing with TypeScript, load testing, smoke testing, an abstract class for CRUD operations, custom exceptions, centralization of constants and environment variables, documentation management with compodoc, and linting with Eslint and Prettier.

Features:

  • Docker-compose environments: Provides two environments for running Docker-compose, located in the env folder at the project's root.
  • Reverse proxy: Implements a URL configuration for easy proxy setup using the jwilder/nginx-proxy package.
  • Refresh token: Implements a refresh token system to allow the frontend to refresh access tokens.
  • Healthcheck: Implements a health check feature for every container.
  • Quality of code: Configures Sonar for code quality checks linked to tests and coverage.
  • Initialization of MongoDB: Includes a script for initializing MongoDB with pre-defined data, such as the admin user.
  • In-memory database: Connects the database to mongodb-memory-server to improve test execution speed.
  • Absolute Path: Removes relative paths at different levels using module-alias for writing only absolute paths.
  • Javascript Typing: The entire codebase is typed using TypeScript.
  • Javascript Typing Coverage: Checks typing coverage using typescript-coverage-report.
  • Load testing: Allows testing the code against concurrency using Artillery.
  • Smoke testing: Rapidly tests the main functionalities of the code using Artillery.
  • CRUD abstract class: Provides an abstract class for creating rapid CRUD operations, which can be extended by services.
  • Shared and custom exceptions: Includes a set of custom exceptions for easily adding new ones based on the Nest.js exceptions.
  • Centralization of constants: Centralizes all constants of the application in one place.
  • Centralization of process environment variables: Centralizes all environment variables for the config module in one place.
  • Documentation: Manages the project's documentation with compodoc.
  • Linter: Adds Eslint and Prettier for enforcing code style rules.

Summary:

The Nest.js template provides a robust and comprehensive foundation for developing scalable applications. With features like Docker-compose environments, a reverse proxy, refresh token functionality, code quality checks, pre-initialized MongoDB, and more, the template aims to improve development efficiency and maintainability. By centralizing constants and environment variables, utilizing proper typing, and providing tools for testing and documentation management, the template promotes best practices and easy customization. Overall, it offers a valuable solution for building Nest.js applications.