This is a boilerplate for NestJS API. It is based on the NestJS framework. It is a TypeScript starter repository.
- JWT Authentication library with access, refresh, confirmation, and reset tokens
Access tokens
are used to authenticate usersRefresh tokens
are used to refresh access tokensConfirmation tokens
are used to confirm user email addressesReset tokens
are used to reset user passwords
- Redis library with
ioredis
to store blacklisted tokens - Configured with
@nestjs/config
to load environment variables from.env
files - Configured with
@nestjs/swagger
to generate Swagger documentation and Swagger example is documented withFaker.js
- Configured with
@nestjs/mongoose
to connect to MongoDB - Configured with Docker and Docker Compose
- Mailer library with
nodemailer
andHandlebars
for templating
Command | Description |
---|---|
yarn start:dev | Start the server in development mode |
yarn build | Build the app for production |
yarn start | Start the app in production mode |
yarn lint | Lint the code |
yarn format | Format the code |
There's a .env.example
file in the src/common/envs
directory. You can copy it to .env
/.env.development
/.env.production
and set the values accordingly.
- You'll need to have Node >= 18.16.1 and yarn >= 1.22.19 on your machine
- Clone this repo using
git clone --depth=1 https://github.com/sonjoydatta/nestjs-boilerplate.git <YOUR_PROJECT_NAME>
- Enter to the project directory:
cd <YOUR_PROJECT_NAME>
- Run
yarn or npm install
in order to install dependencies - At this point you can run
yarn start:dev or npm run start:dev
to see the app athttp://localhost:4000
- You may need to a
.env
file. For development.env.development
You can run the app with Docker and Docker Compose. There's a docker-compose.yml
file in the root directory. You can run docker-compose up
to start the app. You can also run docker-compose up -d
to run the app in the background. You can run docker-compose down
to stop the app.
You can access the Swagger UI at http://localhost:{PORT}
. The default port is 4000
.
- TypeScript
- NestJS
- Swagger
- Faker.js
- MongoDB
- Redis
- class-transformer
- class-validator
- Nodemailer
- Handlebars
- JWT
- bcrypt
- Docker
- Docker Compose
This code is available under the MIT license. See the LICENSE file for more info.