Kind: Interface
Source: packages/common/decorators/http/route-params.decorator.ts
Part of: Common
The @Response()/@Res parameter decorator options.
ResponseDecoratorOptions configures the behavior of NestJS's @Response() (or @Res()) parameter decorator. Its passthrough option determines whether Nest continues its normal response-processing pipeline after injecting the underlying platform response object into a controller handler.
Properties
| Property | Type |
|---|---|
passthrough | boolean |
Diagram
mermaidgraph LR A[Incoming HTTP Request] --> B[Controller Handler] B --> C["@Res() / @Response()"] C --> D[ResponseDecoratorOptions] D --> E{passthrough?} E -->|false or omitted| F[Handler manages response manually] E -->|true| G[Nest processes returned value] G --> H[HTTP Response] F --> H
Usage
tsimport { Controller, Get, Res } from '@nestjs/common';
import type { Response } from 'express';
@Controller('health')
export class HealthController {
@Get()
check(@Res({ passthrough: true }) response: Response) {
response.setHeader('X-Service-Status', 'healthy');
// Nest still serializes and sends this returned value.
return { status: 'ok' };
}
}
AI Coding Instructions
- Use
@Res({ passthrough: true })when a handler needs to set headers, cookies, or status codes while still returning a value for Nest to serialize. - Without
passthrough: true, the handler is responsible for sending the response, such as withresponse.json()orresponse.send(). - Avoid mixing manual response sending with returned response data when passthrough is enabled; this can cause duplicate-response errors.
- Keep response types aligned with the configured HTTP platform, such as Express
Responseor FastifyFastifyReply.
Was this page helpful?