Kind: Constant
Source: packages/common/decorators/http/request-mapping.decorator.ts
Part of: Common
Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
Delete is a route handler decorator that maps an HTTP DELETE request to a controller method. Use it to define endpoints responsible for removing resources or performing delete-oriented actions at a specified path.
Definition
tscreateMappingDecorator(RequestMethod.DELETE)
Value
tscreateMappingDecorator(RequestMethod.DELETE)
Diagram
mermaidgraph LR Client[HTTP Client] -->|DELETE /users/:id| Router[HTTP Router] Router -->|matches route| Controller[Controller Method] Controller -->|@Delete(':id')| Handler[Delete Handler] Handler --> Response[HTTP Response]
Usage
tsimport { Controller, Delete, Param } from '@nestjs/common';
@Controller('users')
export class UsersController {
@Delete(':id')
async remove(@Param('id') id: string) {
await this.usersService.remove(id);
return {
message: `User ${id} deleted successfully`,
};
}
}
AI Coding Instructions
- Apply
@Delete()only to controller methods that handle HTTPDELETErequests. - Provide a route path such as
':id'when the handler deletes a specific resource. - Use parameter decorators like
@Param()to access path values required by the delete operation. - Delegate deletion logic to a service layer rather than placing persistence logic directly in the controller.
- Return an appropriate response or configure the expected HTTP status code for successful deletion.
Used by
7 references from 7 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (7)
DatabaseController—integration/inspector/src/database/database.controller.ts:14DogsController—integration/inspector/src/dogs/dogs.controller.ts:14UsersController—integration/inspector/src/users/users.controller.ts:14UsersController—integration/repl/src/users/users.controller.ts:14UsersController—sample/05-sql-typeorm/src/users/users.controller.ts:14CatsController—sample/06-mongoose/src/cats/cats.controller.ts:7UsersController—sample/07-sequelize/src/users/users.controller.ts:6
Was this page helpful?