# Status Decorator operation response
Module | import { Status } from "@tsed/common" |
---|---|
Source | /packages/common/src/mvc/decorators/method/status.ts |
# Overview
function Status(code: number, options?: Partial<TsED.ResponseOptions>): Function;
# Description
Set the HTTP status for the response. It is a chainable alias of Node’s response.statusCode
.
@Status(204)
async myMethod() {}
1
2
2
With swagger description:
@Status(204, {
type: Model
description: "Description"
})
@Header('Content-Type', 'application-json')
async myMethod() {
}
1
2
3
4
5
6
7
2
3
4
5
6
7
This example will produce the swagger responses object:
{
"responses": {
"404": {
"description": "Description",
"headers": {
"Content-Type": {
"type": "string"
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing