Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NestJS + Prisma Boilerplate

NestJS TypeScript Prisma PostgreSQL PNPM Docker License


Prisma, PostgreSQL, JWT Authentication, CLS Transaction Handling

Overview

  • NestJS 11 + TypeScript + Prisma
  • PostgreSQL 마이그레이션 워크플로우 포함
  • 토큰 기반 JWT Access/Refresh 인증
  • nestjs-cls 기반 요청 컨텍스트 및 트랜잭션 처리
  • Jest/Supertest 기반 테스트 구성

Architecture

  • DDD 지향 계층 구조 (presentation / application / domain / infrastructure)
  • Clean Architecture를 엄격하게 따르기보다는, NestJS 개발 환경 흐름에 맞춘 구성

Stack

  • Framework: NestJS
  • Language: TypeScript
  • ORM: Prisma
  • Database: PostgreSQL
  • Auth: Passport + JWT
  • Validation: class-validator, class-transformer, Joi
  • Logging: Winston, nest-winston
  • Docs: Swagger (비프로덕션)
  • Testing: Jest, Supertest

Project Structure

src
├── auth
│   ├── application
│   ├── domain
│   ├── infrastructure
│   └── presentation
├── user
│   ├── application
│   ├── domain
│   ├── infrastructure
│   └── presentation
├── infrastructure
│   ├── cls
│   ├── database/prisma
│   └── logger
├── common
├── health
├── app.module.ts
└── main.ts

Quick Start

1) Prerequisites

  • Node.js 22+
  • pnpm
  • Docker (선택, 로컬 PostgreSQL 컨테이너 사용 시)

2) Install Dependencies

pnpm install

3) Configure Environment

cp .env.example .env

4) Start Database

docker compose up -d

로컬 PostgreSQL을 직접 써도 괜찮음 (DB_URL만 맞추면 됨)

5) Generate Prisma Client and Run Migration

pnpm prisma:generate
pnpm prisma:migrate

6) Run Application

pnpm start:dev

기본 주소: http://localhost:3000
Swagger 주소(비프로덕션): http://localhost:3000/api-docs

Scripts

# build
pnpm build

# run
pnpm start:dev
pnpm start:prod

# lint / format
pnpm lint
pnpm format

# test
pnpm test
pnpm test:watch
pnpm test:cov
pnpm test:e2e
pnpm test:auth
pnpm test:user

# prisma
pnpm prisma:generate
pnpm prisma:migrate
pnpm prisma:studio

Container

docker build -t nestjs-ddd-boilerplate .
docker run --env-file .env -p 3000:3000 nestjs-ddd-boilerplate

About

nestjs-boilerplate

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages