Interface Response<T>

The response object returned from an endpoint function.

Example returning JSON:

return {
body: {
foo: "bar"

Example returning plaintext and custom headers and status code:

return {
statusCode: 404,
headers: {
"x-request-id": "123"
body: "nobody's home"

See the property descriptions below for further details on allowed data types, default headers, and default status codes.

Type Parameters


  • Response


body?: T

The body of the response.


The content type in parentheses is the default and can be overridden in headers.

headers?: {
    [key: string]: string;

An object mapping lower-case HTTP header names to their values. The type of body determines the default value of the content-type header.

Type declaration

  • [key: string]: string
statusCode?: number

The HTTP status code to return. Defaults to 200, or 500 if an exception is raised.

Generated using TypeDoc