A boilerplate for creating NestJS applications.
- Databases with Prisma ORM
- Queues with Bull
- Authentication with JWT
- Mail sending with Nodemailer
- Request validation with Joi
- Event emitting with Nest Event Emitter
- A package manager (e.g. npm, yarn, pnpm)
- Node.js
- NestJS CLI
- Redis and PostgreSQL or Docker
- Clone the repository
$ git clone https://github.com/matheuslanduci/nestjs-boilerplate.git
- Install dependencies
$ cd nestjs-boilerplate
$ npm install
-
Copy the
.env.example
file to.env
-
Setup the database
$ npm run db:setup
- Run the application
$ npm run start:dev
- Get the endpoints from the folder
workspaces
. Modules available:
There are some patterns to follow in your imports.
/**
* First, the libraries installed in the project.
*/
import { Module } from '@nestjs/common'
import { PrismaClient } from '@prisma/client'
import { ObjectSchema } from 'joi'
/**
* Then, import the shared components.
*/
import { Validate } from '@shared/decorators/validate.decorator'
import { Auth } from '@shared/decorators/auth.decorator'
/**
* Then, import the providers and controllers required by the module.
*/
import { AppController } from './app.controller'
import { AppService } from './app.service'
/**
* Then, import the manually created modules.
*/
import { AuthModule } from '../auth/auth.module'
import { UserModule } from '../users/users.module'
/**
* Finally, import the other files.
*/
import { CreateUserDto } from './dto/create-user.dto'
import { IUser } from './interfaces/user.interface'