From harness-claude
Defines NestJS controllers for REST API routes with @Controller, method decorators, path/query/body params, versioning, and HTTP codes. Use when creating/modifying endpoints or extracting request data.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Define HTTP route handlers with @Controller, method decorators, params, and versioning
Provides expert guidance on RESTful API design, OpenAPI/Swagger documentation, versioning, error handling, DTOs, pagination, and best practices for NestJS applications. Use for designing endpoints, validation, and filtering.
Creates and configures NestJS modules, controllers, services, DTOs, guards, and interceptors for TypeScript backend apps. Use for REST/GraphQL APIs, dependency injection, JWT/Passport auth, Prisma/TypeORM integration, validation, Swagger docs, and testing.
Creates and configures NestJS modules, controllers, services, DTOs, guards, and interceptors for TypeScript backend applications. Use for REST/GraphQL APIs, dependency injection, JWT/Passport auth, Prisma/TypeORM integration, validation, Swagger docs, and unit/E2E testing.
Share bugs, ideas, or general feedback.
Define HTTP route handlers with @Controller, method decorators, params, and versioning
@Controller('resource') to set the route prefix. Use kebab-case for multi-word resources (@Controller('user-profiles')).@Get(), @Post(), @Put(), @Patch(), @Delete() to bind HTTP methods. Nest the path in the decorator when appropriate: @Get(':id').@Param('id') — path parameter@Query('page') — query string parameter@Body() — full request body (use a DTO class for type safety)@Headers('authorization') — request header@Req() / @Res() — raw Express/Fastify request/response (avoid unless necessary)@Res() unless you need to stream or set custom headers — doing so bypasses NestJS interceptors and exception filters.@HttpCode(201) to @Post() handlers that create resources (default is 200).@Header('Cache-Control', 'no-cache') for static header overrides.@Controller({ path: 'articles', version: '1' })
export class ArticlesController {
constructor(private readonly articlesService: ArticlesService) {}
@Get()
findAll(@Query('page') page = 1, @Query('limit') limit = 20) {
return this.articlesService.findAll({ page, limit });
}
@Get(':id')
findOne(@Param('id', ParseUUIDPipe) id: string) {
return this.articlesService.findOne(id);
}
@Post()
@HttpCode(201)
create(@Body() createArticleDto: CreateArticleDto) {
return this.articlesService.create(createArticleDto);
}
@Patch(':id')
update(@Param('id', ParseUUIDPipe) id: string, @Body() dto: UpdateArticleDto) {
return this.articlesService.update(id, dto);
}
@Delete(':id')
@HttpCode(204)
remove(@Param('id', ParseUUIDPipe) id: string) {
return this.articlesService.remove(id);
}
}
main.ts: app.enableVersioning({ type: VersioningType.URI }). Then use @Controller({ version: '1' }) or @Version('2') on individual handlers.Controllers are the entry point for HTTP requests in NestJS. They are registered in the controllers array of their parent module and are not injectable themselves.
Route ordering: NestJS registers routes in declaration order. Static routes (/articles/trending) must be declared before dynamic routes (/articles/:id) within the same controller to avoid shadowing.
@Res() caution: When you inject @Res(), NestJS hands off response management entirely to you. Interceptors (including serialization and transformation interceptors) will NOT run. If you only need to set headers or status codes, use @HttpCode() and @Header() decorators instead. If you must use @Res(), pass { passthrough: true } to keep NestJS in control: @Res({ passthrough: true }).
Pipe integration: Built-in pipes like ParseIntPipe, ParseUUIDPipe, ParseBoolPipe can be passed directly in the parameter decorator: @Param('id', ParseUUIDPipe) id: string. The pipe validates and transforms before the handler executes.
Versioning strategies: URI (/v1/articles), Header (X-API-Version: 1), Media Type (Accept: application/vnd.api+json;v=1), and Custom are all supported. URI versioning is the most visible and cacheable.
https://docs.nestjs.com/controllers