Skip to content

andrechristikan/ack-nestjs-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Contributors Forks Stargazers Issues MIT License

NestJs NodeJs Typescript MongoDB JWT Jest Yarn Docker

ACK NestJs Boilerplate πŸ”₯ πŸš€

This repo will representative of authentication service and authorization service

ACK NestJs is a Http NestJs v11.x boilerplate. Best uses for backend service.

You can request feature or report bug with following this link

Table of contents

Important

  • Stateful Authorization, using redis-session and JWT.
  • Must run MongoDB as a replication set for database transactions.
  • If you change the environment value of APP_ENV to production, it will disable Documentation.
  • For monitoring, this project will use sentry.io, and sent unhandled error and/or internal server error.
  • Since version 7.4.0, the project uses the ES512 algorithm for JWT authentication.
  • When using multiple protection decorators, they must be applied in the correct order:
    @ExampleDoc()
    @PolicyAbilityProtected({...})
    @PolicyRoleProtected(...)
    @UserProtected()     
    @AuthJwtAccessProtected()
    @ApiKeyProtected()
    @Get('/some-endpoint')

TODO

  • Improve eslint rule for better code quality (high priority, in v8)
  • Move some function in service layer into repository module, because a bit wrong implementation (high priority, in v8
  • 2FA Feats (high priority, in v8)
  • Reset password (medium priority, in v8)
  • Export Module in Background using bullmq (medium priority, in v8)
  • Unit test (medium priority)
  • Add Github SSO (low priority)
  • Privacy Policy Module (versioning, lowest priority)
  • Term and Condition Module (versioning, lowest priority)

Support me

If you find this project helpful and would like to support its development, you can buy me a coffee

or support via PayPal

Prerequisites

I assume that everyone who comes here is a programmer with intermediate knowledge. To get the most out of this project, here's what you should understand:

  1. NestJs Fundamentals, as the main Framework. A NodeJs Framework with full TypeScript support.
  2. Typescript Fundamentals, as the main Programming Language. This will help you read and write the code.
  3. ExpressJs Fundamentals, as the base NodeJs Framework. This will help you understand how the NestJs Framework works.
  4. Understanding of databases, especially NoSQL and MongoDB.
  5. Repository Design Pattern or Data Access Object Design Pattern. This will help in reading and writing the source code.
  6. The SOLID Principle for better code writing.
  7. Optional. Microservice Architecture. This can help you understand this project more deeply.
  8. Optional. The Twelve Factor Apps. This can help with project deployment.
  9. Optional. Docker.

Build with

The project is built using the following technologies and versions:

Name Version
NestJs v11.x
NestJs Swagger v11.0.x
Node v22.13.x
Typescript v5.8.x
Mongoose v8.12.x
MongoDB v8.x
Yarn v1.22.x
Docker v27.4.x
Docker Compose v2.31.x

Objective

  • Easy to maintenance
  • NestJs Habit
  • Component based / modular folder structure
  • Stateful authentication and authorization
  • Repository Design Pattern
  • Follow Community Guide Line
  • Follow The Twelve-Factor App

Features

Main Features

  • NestJs 11.x πŸ₯³
  • Typescript πŸš€
  • Production ready πŸ”₯
  • MongoDB integrate by using mongoose πŸŽ‰
  • Cached response with redis.
  • Queue bullmq with redis.
  • Logger with pino 🌲
  • SWC (Speedy Web Compiler) Compiler, fast compiler.
  • Authorization, Role, and session Management (can revoke).
  • Repository Design Pattern.
  • Authentication (Access Token, Refresh Token, API Key, Google SSO, Apple SSO)
  • Export data with CSV or Excel by using decorator.
  • Support multi-language i18n πŸ—£, can controllable with request header x-custom-lang
  • Request validation for all request params, query, dan body with class-validation
  • Swagger / OpenAPI 3 included.
  • Url Versioning, default version is 1.
  • Server Side Pagination.
  • Sentry.io for Monitoring Tools.
  • Support Docker installation.
  • Husky GitHook for run linter before commit 🐢.
  • Linter with EsLint for Typescript.

Installation

For detailed installation instructions (both standard and Docker-based), please refer to the Installation.

Migration

The project includes a migration system for populating the database with initial data using nestjs-command. Migration functions include:

  • Seeding default API keys, countries, roles, and users
  • Managing email templates for the notification system
  • Commands for adding or removing seed data

For complete documentation and instructions on using migrations, see the Migration.

License

Distributed under MIT licensed.

Contribute

I welcome contributions to this project! To contribute, follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature-name.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/your-feature-name.
  5. Open a pull request.

Please ensure your code follows the project's coding standards and includes appropriate tests.

If your branch is behind the origin/main branch, please update your branch and resolve any conflicts before opening a pull request.

Contact

Andre Christi kan

Github LinkedIn