Skip to content

ean-studio/nestjs-enterprise-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NestJS Enterprise Template

๐Ÿ—๏ธ ๊ธฐ์ˆ  ์Šคํƒ

Backend

  • NestJS + Nestia

    • @nestia/core๋ฅผ ํ™œ์šฉํ•œ ํƒ€์ž… ์•ˆ์ „ํ•œ API ๊ฐœ๋ฐœ
    • OpenAPI ๊ธฐ๋ฐ˜ ์ž๋™ ๋ฌธ์„œํ™” ์ง€์›
    • DTO์™€ @TypedRoute, @TypedBody ๋“ฑ์˜ ํƒ€์ž… ์•ˆ์ „ ๊ธฐ๋Šฅ ํ™œ์šฉ
  • Prisma + PostgreSQL

    • AWS PostgreSQL์„ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋กœ ์‚ฌ์šฉ
    • UUID v7์„ ๊ธฐ๋ณธ ID ํ˜•์‹์œผ๋กœ ์‚ฌ์šฉ
    • ํŠธ๋žœ์žญ์…˜๊ณผ ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ฒ˜๋ฆฌ ์ง€์›

๐Ÿ” ์ธ์ฆ ์‹œ์Šคํ…œ

  • JWT ๊ธฐ๋ฐ˜ ์ธ์ฆ
  • AccessToken์€ ์ฟ ํ‚ค/ํ—ค๋”๋กœ ์ฒ˜๋ฆฌ
  • ํ–ฅํ›„ RefreshToken + ์„ธ์…˜ ๊ธฐ๋ฐ˜ ํ™•์žฅ ๊ณ ๋ ค ์ค‘

๐Ÿ“Š ๋ฐ์ดํ„ฐ ๋ชจ๋ธ

ERD (Entity Relationship Diagram)

erDiagram
"users" {
  String id PK
  String name "nullable"
  String avatar "nullable"
  DateTime created_at
  DateTime updated_at
}
"accounts" {
  String id PK
  String user_id FK
  String email UK
  String password
  DateTime created_at
  DateTime updated_at
  DateTime deleted_at "nullable"
}
"social_accounts" {
  String id PK
  String user_id FK
  String provider
  String provider_id UK
  String email
  String name "nullable"
  String avatar "nullable"
  Json metadata "nullable"
  DateTime created_at
  DateTime updated_at
}
"accounts" |o--|| "users" : user
"social_accounts" }o--|| "users" : user
Loading

ํ…Œ์ด๋ธ” ๊ตฌ์กฐ

users

  • ๊ธฐ๋ณธ ์‚ฌ์šฉ์ž ์ •๋ณด ๊ด€๋ฆฌ
  • ํ•„๋“œ:
    • id: UUID v7
    • name: ์‚ฌ์šฉ์ž ์ด๋ฆ„ (nullable)
    • avatar: ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ URL (nullable)
    • created_at: ์ƒ์„ฑ ์‹œ๊ฐ„
    • updated_at: ์ˆ˜์ • ์‹œ๊ฐ„

accounts

  • ์ด๋ฉ”์ผ/๋น„๋ฐ€๋ฒˆํ˜ธ ๊ธฐ๋ฐ˜ ๊ณ„์ • ๊ด€๋ฆฌ
  • ํ•„๋“œ:
    • id: UUID v7
    • user_id: users ํ…Œ์ด๋ธ” ์ฐธ์กฐ
    • email: ์ด๋ฉ”์ผ (unique)
    • password: ์•”ํ˜ธํ™”๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ
    • created_at: ์ƒ์„ฑ ์‹œ๊ฐ„
    • updated_at: ์ˆ˜์ • ์‹œ๊ฐ„
    • deleted_at: ์‚ญ์ œ ์‹œ๊ฐ„ (nullable)

social_accounts

  • ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ณ„์ • ๊ด€๋ฆฌ
  • ํ•„๋“œ:
    • id: UUID v7
    • user_id: users ํ…Œ์ด๋ธ” ์ฐธ์กฐ
    • provider: ์†Œ์…œ ์ œ๊ณต์ž (์˜ˆ: google, github)
    • provider_id: ์†Œ์…œ ์ œ๊ณต์ž์˜ ์‚ฌ์šฉ์ž ID
    • email: ์ด๋ฉ”์ผ
    • name: ์‚ฌ์šฉ์ž ์ด๋ฆ„ (nullable)
    • avatar: ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ URL (nullable)
    • metadata: ์ถ”๊ฐ€ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ (JSON, nullable)
    • created_at: ์ƒ์„ฑ ์‹œ๊ฐ„
    • updated_at: ์ˆ˜์ • ์‹œ๊ฐ„

๐Ÿ’ป ๊ฐœ๋ฐœ ๊ฐ€์ด๋“œ๋ผ์ธ

์ฝ”๋“œ ์Šคํƒ€์ผ

  • ํƒ€์ž… ์•ˆ์ „์„ฑ ์ตœ์šฐ์„ 
  • RESTful API ์„ค๊ณ„
  • ๊ณตํ†ต HttpExceptionFilter๋ฅผ ํ†ตํ•œ ์—๋Ÿฌ ์ฒ˜๋ฆฌ
  • ์„œ๋น„์Šค ๋ ˆ์ด์–ด์—์„œ PrismaClient ์ง์ ‘ ์‚ฌ์šฉ
  • ์ง์ ‘์ ์ธ SQL ์ž‘์„ฑ ์ง€์–‘
  • Fat Controller ์ง€์–‘

Prettier ์„ค์ •

  • ์„ธ๋ฏธ์ฝœ๋ก  ์‚ฌ์šฉ (semi: true)
  • ๋ชจ๋“  ๊ณณ์— ํ›„ํ–‰ ์‰ผํ‘œ ์‚ฌ์šฉ (trailingComma: "all")
  • ์ž‘์€๋”ฐ์˜ดํ‘œ ์‚ฌ์šฉ (singleQuote: true)
  • ํ•œ ์ค„ ์ตœ๋Œ€ ๊ธธ์ด 120์ž (printWidth: 120)
  • ๋“ค์—ฌ์“ฐ๊ธฐ 2์นธ ์‚ฌ์šฉ (tabWidth: 2)
  • ์ค„ ๋ ๋ฌธ์ž ์ž๋™ ์ฒ˜๋ฆฌ (endOfLine: "auto")

๐Ÿ› ๏ธ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ

ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ €

  • pnpm ์‚ฌ์šฉ

์ฝ”๋“œ ํฌ๋งทํŒ…

npm run format

Nestia ์˜ˆ์‹œ

@TypedRoute.Post()
async createExpense(@TypedBody() body: CreateExpenseDto) {
  return this.expenseService.create(body);
}

About

๐Ÿš€ Production-ready NestJS template with Prisma ORM, structured logging, OpenAPI documentation using Nestia, and enterprise-level architecture. Features type-safe controllers, JWT authentication, and comprehensive error handling.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors