# Status Decorator

Module
import { Status } from "@tsed/common"
Source/packages/common/src/mvc/decorators/method/status.ts

# Overview

function Status(code: number, options?: IResponseOptions): 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

With swagger description:

@Status(204, {
  type: Model
  description: "Description"
})
@Header('Content-Type', 'application-json')
async myMethod() {
}
1
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