Skip to main content

ServerlessResponse

@h4ad/serverless-adapter > ServerlessResponse

(class) ServerlessResponse​

The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request. Once it's happens, we use the properties from this response to built the response to the cloud.

Signature:

export declare class ServerlessResponse extends ServerResponse 

Extends: ServerResponse

(property) _header​

Signature:

_header: string;

(property) _headers​

Signature:

_headers?: Record<any, any>;

(property) _wroteHeader​

Signature:

_wroteHeader?: boolean;

(property) [BODY]​

Signature:

[BODY]: any[];

(property) [HEADERS]​

Signature:

[HEADERS]: Record<any, any>;

(constructor)​

Constructs a new instance of the ServerlessResponse class

Signature:

constructor(\{ method }: ServerlessResponseProps);

Parameters​

Parameter

Type

Description

{ method }

ServerlessResponseProps

(method) body​

Signature:

static body(res: ServerlessResponse): Buffer;

Parameters​

Parameter

Type

Description

res

ServerlessResponse

Returns:

Buffer

(method) callNativeWriteHead​

I use ignore here because in nodejs 12.x, statusMessage can be string | OutgoingHttpHeaders But in nodejs > =14.x, statusMessage can also be OutgoingHttpHeaders[] I take care of these cases above, but here I can't handle it well, so I give up nodejs 12.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v12/http.d.ts\#L229 nodejs 14.x ref: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v14/http.d.ts\#L263

Signature:

protected callNativeWriteHead(statusCode: number, statusMessage?: string | any | any[], obj?: any | any[]): this;

Parameters​

Parameter

Type

Description

statusCode

number

statusMessage

string | any | any[]

(Optional)

obj

any | any[]

(Optional)

Returns:

this

(method) from​

Signature:

static from(res: IncomingMessage): ServerlessResponse;

Parameters​

Parameter

Type

Description

res

IncomingMessage

Returns:

ServerlessResponse

(method) headers​

Signature:

static headers(res: ServerlessResponse): import("http").OutgoingHttpHeaders & Record<any, any>;

Parameters​

Parameter

Type

Description

res

ServerlessResponse

Returns:

import("http").OutgoingHttpHeaders & Record<any, any>

(property) headers​

Signature:

get headers(): Record<any, any>;

(method) setHeader​

Signature:

setHeader(key: string, value: number | string | readonly string[]): any;

Parameters​

Parameter

Type

Description

key

string

value

number | string | readonly string[]

Returns:

any

(method) writeHead​

Signature:

writeHead(statusCode: number, statusMessage?: string | any | any[], obj?: any | any[]): any;

Parameters​

Parameter

Type

Description

statusCode

number

statusMessage

string | any | any[]

(Optional)

obj

any | any[]

(Optional)

Returns:

any