Request Parameters
Instead of a fixed (req, res, next) signature, a RapidREST handler declares exactly what it needs as arguments, in any order, and the framework fills them in before calling it:
@Get('/:id')
async getPet(@Param('id') id: string, @Query('version') version: string, @User user?: JWTUser) {
/* ... */
}
@Param('id') pulls the :id segment out of the path (GET /my-pet → my-pet), @Query('version') pulls a query string value (GET /my-pet?version=3 → 3), @User injects the authenticated caller, if any. The handler's signature already tells you everything it reads from the request, there's no need to go dig through req to find out.
The full set
| Decorator | Resolves to |
|---|---|
@Param(name?) | req.params[name], or the whole params object if name is omitted |
@Query(name?) | req.query[name], or the whole query object if name is omitted |
@Header(name) | req.headers[name] |
@Request | the whole HttpRequest object (no parentheses) |
@Response | the whole HttpResponse object (no parentheses) |
@Socket | the WebSocket connection, for @WebSocket handlers (no parentheses), see WebSockets |
@User | the authenticated user, if any (no parentheses) |
@AuthResult | the full auth result (the strategy name, payload, and user together, no parentheses) |
@Request also carries req.cookies and, if sessions are configured, req.session.
The request body
The first argument that isn't decorated at all is the parsed request body, there's no @Body() to reach for. It can sit anywhere among the decorated arguments:
@Post()
async createPet(pet: Pet) {
// `pet` is the parsed JSON body
return this.petService.create(pet);
}
@Post()
async createPet2(@Query() query: any, pet: Pet, @User user: JWTUser) {
// still just the first undecorated argument, position among the others doesn't matter
return this.petService.create(pet);
}