← ClaudeAtlas

nestjs-patternslisted

NestJS best practices, module architecture, DTOs, Guards, Interceptors, and common patterns. Use when building or reviewing NestJS backend services.
desilokesh1/antigravity-fullstack-hq · ★ 2 · API & Backend · score 75
Install: claude install-skill desilokesh1/antigravity-fullstack-hq
# NestJS Patterns ## Module Structure ``` src/modules/users/ ├── users.module.ts ├── users.controller.ts ├── users.service.ts ├── dto/ │ ├── create-user.dto.ts │ └── update-user.dto.ts ├── entities/ │ └── user.entity.ts └── guards/ └── user-owner.guard.ts ``` ## Key Patterns ### Module Definition ```typescript @Module({ imports: [PrismaModule], controllers: [UsersController], providers: [UsersService], exports: [UsersService], }) export class UsersModule {} ``` ### DTOs with Validation ```typescript import { IsEmail, IsString, MinLength } from 'class-validator' export class CreateUserDto { @IsEmail() email: string @IsString() @MinLength(8) password: string } ``` ### Service Pattern ```typescript @Injectable() export class UsersService { constructor(private readonly prisma: PrismaService) {} async create(dto: CreateUserDto) { return this.prisma.user.create({ data: dto }) } async findOne(id: string) { const user = await this.prisma.user.findUnique({ where: { id } }) if (!user) throw new NotFoundException() return user } } ``` ### Controller Pattern ```typescript @Controller('users') export class UsersController { constructor(private readonly usersService: UsersService) {} @Post() @HttpCode(HttpStatus.CREATED) create(@Body() dto: CreateUserDto) { return this.usersService.create(dto) } @Get(':id') @UseGuards(JwtAuthGuard) findOne(@Param('id') id: string) { return this.usersService.findO