NarHakobyan/awesome-nest-boilerplate(opens in a new tab)
Language: TypeScript
Awesome NestJS Boilerplate š, Typescript šŖ, Postgres š, TypeORM š„³
- stars
- 2,828
- watchers
- 35
- forks
- 520
- open issues
- 3
- Last updated
- 09/20/2026
Language: TypeScript
Awesome NestJS Boilerplate š, Typescript šŖ, Postgres š, TypeORM š„³
An enterprise-grade NestJS starter built for teams that care about code structure at scale. Ships with CQRS, strict TypeScript, JWT auth (RS256), and multi-runtime support ā all wired with zero configuration drift.
# 1. Clone npx degit NarHakobyan/awesome-nest-boilerplate my-nest-app cd my-nest-app # 2. Configure cp .env.example .env # Set DB_HOST, DB_PORT, DB_USERNAME, DB_PASSWORD, DB_DATABASE # Paste your JWT_PRIVATE_KEY and JWT_PUBLIC_KEY (see .env.example for examples) # 3. Install & run pnpm install pnpm start:dev
Open http://localhost:3000. The API docs are at /documentation.
Prefer a database out of the box?
docker-compose up -d postgresfirst.
| CQRS ā Commands, queries, handlers | JWT Auth (RS256) ā Login, register, RBAC | TypeORM + PostgreSQL ā Entities, migrations |
Strict TypeScript ā No any, ESM, verbatim modules |
i18n ā Multi-language (en_US, ru_RU) | Swagger ā Auto-generated API docs |
| Vite HMR ā Instant dev reload | UUID v7 ā Time-sortable primary keys | Biome + ESLint ā Linting & formatting |
| Helmet + Rate Limiting ā Built-in security | CORS ā Configurable origins | Validation ā Custom decorators, DTO guards |
| Node / Bun / Deno ā Multi-runtime | OpenAPI MCP ā AI assistants call your API |
A typical CQRS flow ā command, handler, and service wired through NestJS DI:
// āā Command āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā export class CreatePostCommand extends Command { constructor( public readonly userId: Uuid, public readonly dto: CreatePostDto, ) { super(); } } // āā Handler āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā @CommandHandler(CreatePostCommand) export class CreatePostHandler { constructor( @InjectRepository(PostEntity) private repo: Repository<PostEntity>, ) {} async execute({ userId, dto }: CreatePostCommand): Promise<PostEntity> { return this.repo.save(this.repo.create({ ...dto, userId })); } } // āā Service āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā @Injectable() export class PostService { constructor(private commandBus: CommandBus) {} @Transactional() create(userId: Uuid, dto: CreatePostDto): Promise<PostEntity> { return this.commandBus.execute(new CreatePostCommand(userId, dto)); } }
flowchart LR
A[Request] --> B[Guard]
B --> C[Controller]
C --> D[Command / Query Bus]
D --> E[Handler]
E --> F[Service]
F --> G[Repository]
G --> H[(PostgreSQL)]
Every feature module follows this structure:
src/
āāā common/ # Shared DTOs, base entity
āāā constants/ # Enums, role types
āāā database/ # Migrations, TypeORM config
āāā decorators/ # @AuthUser, @UUIDParam, @UseDto
āāā filters/ # Global exception filters
āāā guards/ # Auth guards (JWT, roles)
āāā i18n/ # Translation files (en_US, ru_RU)
āāā interceptors/ # Language, translation interceptors
āāā modules/
ā āāā auth/ # JWT auth (RS256), login/register
ā āāā user/ # User CRUD, RBAC
ā āāā post/ # Post CRUD, CQRS example
ā āāā agent/ # AI agent (ai-sdk v6)
ā āāā chat/ # Chat history (JSONB)
āāā shared/ # Global services, config
āāā validators/ # Custom validation decorators
Copy .env.example ā .env. Most variables come pre-configured with working defaults. You only need to change these:
| Variable | What to set |
|---|---|
DB_HOST, DB_PORT, DB_USERNAME, DB_PASSWORD, DB_DATABASE |
PostgreSQL connection (or use docker-compose up -d postgres ā defaults match) |
JWT_PRIVATE_KEY |
RS256 private key ā generate your own or use the example PEM in .env.example |
JWT_PUBLIC_KEY |
RS256 public key ā matching public key |
Every other variable in .env.example has a working default for local development. Optional features (NATS, S3, Email, AI providers) are off by default ā enable them when you need them.
| Node.js | Bun | Deno |
|---|---|---|
pnpm start:dev |
bun start:dev:bun |
deno task start |
pnpm test |
bun test |
deno task test |
pnpm build:prod |
bun build:bun |
deno task buildr |
Node is the primary runtime. Bun and Deno support is included for teams that prefer them.
name in package.json.env ā replace the JWT keys and DB credentials with your ownLICENSE ā change the author name