A production-ready NestJS template with built-in authentication, authorization, and module generation.
- Framework: NestJS 11
- Database: PostgreSQL with Prisma ORM
- Validation: Zod + nestjs-zod
- Authentication: JWT (Access & Refresh Tokens)
- Caching: Redis with cache-manager
- Queue: BullMQ
- Email: React Email + Resend
- API Docs: Swagger
- Security: Helmet, Throttler, bcrypt
- 2FA: OTP Auth (TOTP)
- User management with role-based access control (RBAC)
- Permission system
- Soft delete support
- Scheduled tasks (cron jobs)
- Request validation with Zod schemas
- Standardized API responses
Quickly scaffold new CRUD modules with a single command:
pnpm generate:module <module-name>This generates a complete module structure:
src/routes/<module-name>/
├── <module-name>.controller.ts # Full CRUD endpoints
├── <module-name>.module.ts
├── services/
│ └── <module-name>.service.ts # Business logic
├── repository/
│ └── <module-name>.repository.ts # Database operations
├── types/
│ ├── <module-name>.model.ts # Zod schemas & types
│ └── <module-name>.dto.ts # NestJS DTOs
└── utils/
├── <module-name>.config.ts # Search & include config
└── <module-name>.error.ts # Custom exceptions
Generated endpoints:
GET /<module>- List with search, pagination, includesGET /<module>/:id- Get by IDPOST /<module>- CreatePATCH /<module>/:id- UpdateDELETE /<module>/:id- Soft/hard delete
# Install dependencies
pnpm install
# Setup environment
cp .env.example .env
# Run migrations
pnpm migrate:apply
# Start development server
pnpm dev| Command | Description |
|---|---|
pnpm dev |
Start development server |
pnpm build |
Build for production |
pnpm start:prod |
Run production build |
pnpm generate:module |
Generate new module |
pnpm prisma:studio |
Open Prisma Studio |
pnpm migrate:dev |
Create migration |
pnpm migrate:apply |
Apply migrations |
Peterxyjz
MIT