Rulebook

Claude Rules 관리

문서맵
  • component-design
  • entities-api
  • entities-layer
  • entities-model
  • error-handling
  • features-layer
  • fsd-architecture
  • react-hooks
    1
  • security
  • server-components
  • shared-layer
  • tailwind-css
  • tanstack-query
  • testing
  • views-layer
  • widget-layer
  • changelog
  • development-workflow
  • documentation
  • git-commit
  • marketing-seo
  • marketing-ux
  • naming-convention
  • security
  • typescript-standards
  • ux-copy-and-tone
  • api-design
  • database
  • nest
  • security
  • supabase
  • README
전체 룰 다운로드
back/nest
activev12026. 4. 12.

description: "NestJS 아키텍처 및 패턴" paths:

  • "**/*.controller.ts"
  • "**/*.service.ts"
  • "**/*.module.ts"
  • "**/*.guard.ts"
  • "**/*.dto.ts"

NestJS Guidelines

모듈 구조

src/
├── app.module.ts
├── (도메인)/
│   ├── (도메인).module.ts
│   ├── (도메인).controller.ts
│   ├── (도메인).service.ts
│   ├── dto/
│   │   ├── create-(도메인).dto.ts
│   │   └── update-(도메인).dto.ts
│   └── entities/
│       └── (도메인).entity.ts
└── common/
    ├── guards/
    ├── filters/
    └── interceptors/

레이어 역할

  • Controller: 요청/응답 처리, 유효성 검사만. 비즈니스 로직 없음
  • Service: 비즈니스 로직 담당
  • PrismaService: DB 쿼리 담당 (Service 에서 직접 주입)

DTO

class-validator를 사용해 입력 유효성 검사

export class CreateUserDto {
  @IsEmail()
  email: string;

  @IsString()
  @MinLength(8)
  password: string;
}

에러 처리

NestJS 내장 예외를 사용한다.

throw new NotFoundException(`User ${id} not found`);
throw new BadRequestException('Invalid input');
throw new UnauthorizedException();

원칙

  • Controller는 얇게 유지 (로직은 Service로)
  • 하나의 Service는 하나의 도메인 책임
  • 순환 의존성 금지

피드백 0

아직 피드백이 없어요. 첫 번째로 의견을 남겨보세요!

목차

모듈 구조레이어 역할DTO에러 처리원칙