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

ParameterTypeDescription
{ method }ServerlessResponseProps

(method) body

Signature:

static body(res: ServerlessResponse): Buffer;

Parameters

ParameterTypeDescription
resServerlessResponse

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

ParameterTypeDescription
statusCodenumber
statusMessagestring | any | any[](Optional)
objany | any[](Optional)

Returns:

this

(method) from

Signature:

static from(res: IncomingMessage): ServerlessResponse;

Parameters

ParameterTypeDescription
resIncomingMessage

Returns:

ServerlessResponse

(method) headers

Signature:

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

Parameters

ParameterTypeDescription
resServerlessResponse

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

ParameterTypeDescription
keystring
valuenumber | string | readonly string[]

Returns:

any

(method) writeHead

Signature:

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

Parameters

ParameterTypeDescription
statusCodenumber
statusMessagestring | any | any[](Optional)
objany | any[](Optional)

Returns:

any