ACK NestJs Boilerplate 🔥 🚀
This repo will representative of authentication service and authorization service
[ACK NestJs][ack] is a Http NestJs v10.x boilerplate. Best uses for backend service.
You can request feature or report bug with following this link
Table of contents
- ACK NestJs Boilerplate 🔥 🚀
Important
Very limited documentation
- Stateful Authorization, using
redis-session
andJWT
. - Must run MongoDB as a
replication set
fordatabase transactions
. - If you want to implement
Google SSO
. You must have google cloud console account, then create your own Credential to get theclientId
andclientSecret
. - If you want to implement
Apple SSO
. You must haveclientId
andsignInClientId
. - If you change the environment value of
APP_ENV
toproduction
, that will disable Documentation. - For monitoring, this project will use
sentry.io
, and sent uncatched error and/orinternal server error
.
TODO
- Export Module
- Move to Stateful Authorization 1. Reset Password Module 2. Verification Module
Prerequisites
We assume that everyone who comes here is programmer with intermediate knowledge
and we also need to understand more before we begin in order to reduce the knowledge gap.
- Understand NestJs Fundamental, Main Framework. NodeJs Framework with support fully TypeScript.
- Understand Typescript Fundamental, Programming Language. It will help us to write and read the code.
- Understand ExpressJs Fundamental, NodeJs Base Framework. It will help us in understanding how the NestJs Framework works.
- Understand what and how database works, especially NoSql and MongoDB.
- Understand Repository Design Pattern or Data Access Object Design Pattern. It will help to read, and write the source code
- Understand The SOLID Principle and KISS Principle for better write the code.
- Optional. Understand Microservice Architecture, Clean Architecture, and/or Hexagonal Architecture. It can help you to understand more deep about this project.
- Optional. Understanding The Twelve Factor Apps. It can help to serve the project.
- Optional. Understanding Docker.
Build with
Describes which version.
Name | Version |
---|---|
NestJs | v10.x |
NestJs Swagger | v8.0.x |
NodeJs | v22.11.x |
Typescript | v5.6.x |
Mongoose | v10.0.x |
MongoDB | v8.x |
Yarn | v1.22.x |
Docker | v27.2.x |
Docker Compose | v2.29.x |
Objective
- Easy to maintenance
- NestJs Habit
- Component based / modular folder structure
- Stateless authentication and authorization
- Repository Design Pattern or Data Access Layer Design Pattern
- Follow Community Guide Line
- Follow The Twelve-Factor App
Features
Main Features
- NestJs 10.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 headerx-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
Before start, we need to install some packages and tools.
The recommended version is the LTS version for every tool and package.
Make sure to check that the tools have been installed successfully.
Clone Repo
Clone the project with git.
git clone https://github.com/andrechristikan/ack-nestjs-boilerplate.git
Install Dependencies
This project needs some dependencies. Let's go install it.
yarn install
Create environment
Make your own environment file with a copy of env.example
and adjust values to suit your own environment.
cp .env.example .env
Database Migration and Seed
By default the options of AutoCreate
and AutoIndex
will be false
.
Thats means the schema in MongoDb will not change with the latest.
So in the first place, u need to update the schema
yarn migrate:schema
After migrate the schema, also we need to run data seed
yarn seed
Template Migration
Optional
The template migration will automatically upload /templates
through AWS SES.
For migrate
yarn migrate:template
Run Project
Finally, Cheers 🍻🍻 !!! you passed all steps.
Now you can run the project.
yarn start:dev
Installation with Docker
We need more tools to be installed.
Copy .env.example
and change value
DATABASE_URL
:DATABASE_URL=mongodb://host.docker.internal:27017,host.docker.internal:27018,host.docker.internal:27019/ack?retryWrites=true&w=majority&replicaSet=rs0
REDIS_HOST
:redis
leave the rest as it, then run
docker-compose up -d
Test
The project only provide unit testing
.
yarn test
Swagger
You can check The Swagger after running this project. Url localhost:3000/docs
API Key
api key: v8VB0yY887lMpTA2VJMV
api key secret: zeZbtGTugBTn3Qd5UXtSZBwt7gn3bg
User
- Super Admin
- email:
superadmin@mail.com
- password:
aaAA@123
- email:
- Admin
- email:
admin@mail.com
- password:
aaAA@123
- email:
- Member
- email:
member@mail.com
- password:
aaAA@123
- email:
- User
- email:
user@mail.com
- password:
aaAA@123
- email:
BullMQ Board
This available with docker installation
You can check and monitor your queue.
Url localhost:3010
User
- email:
admin
- password:
admin123
License
Distributed under MIT licensed.
Contribute
How to contribute in this repo
- Fork the repository
- Create your branch
git checkout -b my-branch
- Commit any changes to your branch
- Push your changes to your remote branch
- Open a pull request
If your code behind commit with the origin/main
branch, please update your code and resolve the conflict.