NarHakobyan/awesome-nest-boilerplate
์๊ฐ
Awesome NestJS Boilerplate ๐, TypeScript ๐ช, Postgres ๐, TypeORM ๐ฅณ
ํ์ต ๋ฐ ๊ต์ก์ธก์ ๋ ์คํ ์ฆ๊ฐ
- in 24h
- -1
- in 7 days
- -3
- in 15 days
- -5
- in 1 month
- -5
์๋ก ๊ฒน์น๋ ๊ธฐ๊ฐ์ ์์ฆ๊ฐ๋์ด๋ฉฐ ์ผ๋ณ ํฉ๊ณ๊ฐ ์๋๋๋ค. ์ธก์ ๊ฐ์ด ์์ผ๋ฉด ๋น์ ๋ก๋๋ค. ์คํ๋ ๊ด์ฌ๋๋ฅผ ๋ํ๋ด๋ฉฐ ํ์ง์ ๋ณด์ฅํ์ง ์์ต๋๋ค.
README.md
OriginalAwesome NestJS Boilerplate v11
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.
Quick Start
# 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.
What's Inside
| 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 |
Taste of the Codebase
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));
}
}
Architecture
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
Environment Variables
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.
Multi-Runtime Support
| 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.
Making It Your Own
- Rename the project โ update
nameinpackage.json - Update
.envโ replace the JWT keys and DB credentials with your own - Update
LICENSEโ change the author name - Customize this README โ replace it with your project's docs
Documentation
- Architecture โ CQRS, repository pattern, DI, entity-DTO mapping
- Setup & Development โ first-time setup, scripts, debugging
- Code Generation โ NestJS schematics for scaffolding
- Naming Cheatsheet โ file, class, and variable conventions
- Linting โ Biome + ESLint setup
- OpenAPI MCP โ AI assistants calling your API
Community
๊ด๋ จ ํ๋ก์ ํธ ์ดํด๋ณด๊ธฐ
๋ถ๋ฌ์ค๋ ์คโฆ