When to use this skill
- When creating new API endpoints or controllers (*.controller.ts files)
- When modifying existing HTTP route handlers in NestJS controllers
- When adding or updating Swagger/OpenAPI documentation decorators
- When implementing route-level authentication and authorization (guards, @Public, @MemberRoles)
- When defining request DTOs for query params, route params, or request bodies
- When defining response DTOs and handling HTTP status codes
- When working with files in
features/{feature}/controller/orauth/controller/directories - When using API_ENDPOINTS constants from @imkdw-dev/consts
- When structuring controller constructor dependency injection
Backend API
This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle backend API.
Instructions
For details, refer to the information provided in this file: backend API
Project-Specific Patterns
Controller Structure
@ApiTags('Feature Name')
@Controller()
@MemberRoles(MEMBER_ROLE.ADMIN) // Default role guard
export class FeatureController {
constructor(
private readonly createUseCase: CreateUseCase,
private readonly updateUseCase: UpdateUseCase,
private readonly getQuery: GetQuery
) {}
}
Route Handler Pattern
@Swagger.getItems('Description')
@Public() // For public endpoints
@Get(API_ENDPOINTS.GET_ITEMS)
async getItems(@Query() query: RequestDto): Promise<ResponseDto> {
return this.query.execute(query);
}
@Swagger.createItem('Description')
@Post(API_ENDPOINTS.CREATE_ITEM)
async createItem(@Body() dto: CreateDto) {
const result = await this.useCase.execute(dto);
return ResponseDto.from(result);
}
@Swagger.updateItem('Description')
@HttpCode(HttpStatus.NO_CONTENT)
@Put(API_ENDPOINTS.UPDATE_ITEM)
async updateItem(@Param('id') id: string, @Body() dto: UpdateDto): Promise<void> {
await this.useCase.execute(id, dto);
}
Key Conventions
- Use
HttpStatus.NO_CONTENTfor update/delete operations returning void - Separate read operations (Query classes) from write operations (UseCase classes)
- Import API endpoints from
@imkdw-dev/constspackage - Use feature-specific Swagger decorators from
swagger/{feature}.swagger.ts