Skip to main content

ApiGatewayV2Adapter

@h4ad/serverless-adapter > ApiGatewayV2Adapter

(class) ApiGatewayV2Adapter

The adapter to handle requests from AWS Api Gateway V2

As per know issues , we throw an exception when you send the transfer-encoding=chunked . But, if you use this adapter to accept requests from Function URL, you can accept the transfer-encoding=chunked changing the method of invocation from BUFFERED to RESPONSE_STREAM .

Signature:

export declare class ApiGatewayV2Adapter implements AdapterContract<APIGatewayProxyEventV2, Context, APIGatewayProxyStructuredResultV2> 

Implements: AdapterContract <APIGatewayProxyEventV2, Context, APIGatewayProxyStructuredResultV2>

Example

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

Event Reference

(constructor)

Default constructor

Signature:

constructor(options?: ApiGatewayV2Options | undefined);

Parameters

Parameter

Type

Description

options

ApiGatewayV2Options | undefined

(Optional) The options to customize the ApiGatewayV2Adapter

(method) canHandle

Signature:

canHandle(event: unknown): event is APIGatewayProxyEventV2;

Parameters

Parameter

Type

Description

event

unknown

Returns:

event is APIGatewayProxyEventV2

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: APIGatewayProxyEventV2): string;

Parameters

Parameter

Type

Description

event

APIGatewayProxyEventV2

The event sent by serverless

Returns:

string

(method) getRequest

Signature:

getRequest(event: APIGatewayProxyEventV2): AdapterRequest;

Parameters

Parameter

Type

Description

event

APIGatewayProxyEventV2

Returns:

AdapterRequest

(method) getResponse

Signature:

getResponse(\{ headers: responseHeaders, body, isBase64Encoded, statusCode, response, }: GetResponseAdapterProps<APIGatewayProxyEventV2>): APIGatewayProxyStructuredResultV2;

Parameters

Parameter

Type

Description

{ headers: responseHeaders, body, isBase64Encoded, statusCode, response, }

GetResponseAdapterProps <APIGatewayProxyEventV2>

Returns:

APIGatewayProxyStructuredResultV2

(method) onErrorWhileForwarding

Signature:

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

Parameters

Parameter

Type

Description

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

OnErrorProps <APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2>

Returns:

void

(property) options

Signature:

protected readonly options?: ApiGatewayV2Options | undefined;

(property) stripPathFn

Strip base path function

Signature:

protected stripPathFn: StripBasePathFn;