Skip to main content

HttpFunctionAdapter

@h4ad/serverless-adapter > HttpFunctionAdapter

(class) HttpFunctionAdapter

The adapter to handle requests from Digital Ocean Functions when called from HTTP Endpoint.

Signature:

export declare class HttpFunctionAdapter implements AdapterContract<DigitalOceanHttpEvent, void, DigitalOceanHttpResponse> 

Implements: AdapterContract <DigitalOceanHttpEvent, void, DigitalOceanHttpResponse>

Example

const stripBasePath = '/any/custom/base/path'; // default ''
const adapter = new HttpFunctionAdapter(\{ stripBasePath });

(constructor)

Default constructor

Signature:

constructor(options?: HttpFunctionAdapterOptions | undefined);

Parameters

Parameter

Type

Description

options

HttpFunctionAdapterOptions | undefined

(Optional) The options to customize the HttpFunctionAdapter

(method) canHandle

Signature:

canHandle(event: unknown): event is DigitalOceanHttpEvent;

Parameters

Parameter

Type

Description

event

unknown

Returns:

event is DigitalOceanHttpEvent

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: DigitalOceanHttpEvent): string;

Parameters

Parameter

Type

Description

event

DigitalOceanHttpEvent

The event sent by digital ocean

Returns:

string

(method) getRequest

Signature:

getRequest(event: DigitalOceanHttpEvent): AdapterRequest;

Parameters

Parameter

Type

Description

event

DigitalOceanHttpEvent

Returns:

AdapterRequest

(method) getResponse

Signature:

getResponse(\{ headers: responseHeaders, body, statusCode, }: GetResponseAdapterProps<DigitalOceanHttpEvent>): DigitalOceanHttpResponse;

Parameters

Parameter

Type

Description

{ headers: responseHeaders, body, statusCode, }

GetResponseAdapterProps <DigitalOceanHttpEvent>

Returns:

DigitalOceanHttpResponse

(method) onErrorWhileForwarding

Signature:

onErrorWhileForwarding(\{ error, delegatedResolver, respondWithErrors, event, log, }: OnErrorProps<DigitalOceanHttpEvent, DigitalOceanHttpResponse>): void;

Parameters

Parameter

Type

Description

{ error, delegatedResolver, respondWithErrors, event, log, }

OnErrorProps <DigitalOceanHttpEvent, DigitalOceanHttpResponse>

Returns:

void

(property) options

Signature:

protected readonly options?: HttpFunctionAdapterOptions | undefined;