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 tokensare used to authenticate usersRefresh tokensare used to refresh access tokensConfirmation tokensare used to confirm user email addressesReset tokensare used to reset user passwords
- Redis library with
ioredisto store blacklisted tokens - Configured with
@nestjs/configto load environment variables from.envfiles - Configured with
@nestjs/swaggerto generate Swagger documentation and Swagger example is documented withFaker.js - Configured with
@nestjs/mongooseto connect to MongoDB - Configured with Docker and Docker Compose
- Mailer library with
nodemailerandHandlebarsfor 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 installin order to install dependencies - At this point you can run
yarn start:dev or npm run start:devto see the app athttp://localhost:4000 - You may need to a
.envfile. 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.