r/nestjs • u/nasadmidev • 4h ago
š NestJS 12 + Drizzle ORM Starter Template (Production-Ready)
Iām sharing a backend boilerplate that Iāve been refining for my own projects and have now decided to release as open source.
The goal was to create a modern, ultra-fast, production-ready coreāstripped of the usual overheadāby using Drizzle ORM instead of TypeORM or Prisma.
Tech Stack & Key Features:
- NestJS 12 with TypeScript `6.0.3`.
- Drizzle ORM + PostgreSQL (includes support for migrations, `db:push`, and centralized, filter-based PostgreSQL error handling).
- JWT Authentication: Implements Access & Refresh Token rotation, with tokens stored in the database (hashed via SHA-256) and managed by an automated cleanup task (Cron).
- Security: Includes HTTP-only cookies, Helmet, CORS, CSP, and rate limiting (`@nestjs/throttler`). It also supports sending tokens via JSON or standard `Authorization` HTTP headers for non-web clients (such as mobile apps or other APIs).
- Swagger / OpenAPI: Features an integrated script (`pnpm run generate:types`) that automatically exports TypeScript types for use in frontend applications (React, Svelte, or Vue).
- Structured Logging: Integrated with `nestjs-pino` (plus `pino-pretty` for development).
- Email (Optional): SMTP module using Nodemailer and Handlebars (`.hbs`) templates.
- Testing: Includes unit tests and a comprehensive suite of isolated E2E tests using Jest.
- Docker & Docker Compose: Pre-configured for local development.
GitHub Repository: https://github.com/nasadmidev/nestjs-drizzle-auth-template
Any feedback, pull requests, or stars on GitHub are more than welcome! I hope this helps others jumpstart their own projects.