Created by Odenir Gomes
A production-ready NestJS boilerplate featuring:
- User CRUD (registration, retrieval, pagination)
- Validation and global pipes for input sanitization
- Prisma ORM integration (PostgreSQL)
- Automated tests (unit & E2E) using Jest + Supertest
Ideal starting point for new back-end projects with NestJS.
- User module
POST /users→ Create a new userGET /users/:id→ Fetch user by IDGET /users→ Paginated list of users
- DTOs & Pipes: Input validation via
class-validatorand customQueryPipe - Prisma: Database modeling, migrations, type-safe client
- Testing:
- Unit tests for services and controllers
- E2E tests with isolated test database
- Environment support:
development,production,test
- Clone the repo
git clone https://github.com/your-org/boilerplate-nestjs.git cd boilerplate-nestjs - Install dependencies
npm install # or yarn install
Create a .env file in the project root:
# Development environment
NODE_ENV=development
DATABASE_URL="postgres://user:password@localhost:5432/mydatabase"For testing, copy and adjust to .env.test:
NODE_ENV=test
DATABASE_URL="postgres://user:password@localhost:5432/mydatabase_test"- Start PostgreSQL via Docker Compose:
docker-compose up -d db
- Run the application in dev mode:
npm run start:dev # or yarn start:dev - Visit
http://localhost:3000
npm run build
npm run start:prodnpm run test
# or
yarn testnpm run test:e2e
# or
yarn test:e2esrc/
├── app.module.ts # Root module
├── main.ts # Application entrypoint
├── modules/
│ └── user/
│ ├── dtos/ # UserDto, PaginatedRequestDto
│ ├── services/ # UserService
│ └── user.controller.ts
├── shared/
│ ├── prisma/ # PrismaService
│ ├── utils/ # BaseController, Result types
│ └── pipes/ # QueryPipe
prisma/
├── schema.prisma
└── migrations/
test/
├── global-setup.ts # DB setup for tests
├── app.e2e-spec.ts
└── user.e2e-spec.ts
- Fork the repository
- Create a feature branch:
git checkout -b feature/foo - Commit your changes:
git commit -m 'feat: add foo' - Push to the branch:
git push origin feature/foo - Open a Pull Request
MIT © Odenir Gomes