Skip to main content

ApiGatewayV1Adapter

@h4ad/serverless-adapter > ApiGatewayV1Adapter

(class) ApiGatewayV1Adapter

The adapter to handle requests from AWS Api Gateway V1

As per know issues , we throw an exception when you send the transfer-encoding=chunked , currently, API Gateway doesn't support chunked transfer.

Signature:

export declare class ApiGatewayV1Adapter implements AdapterContract<APIGatewayProxyEvent, Context, APIGatewayProxyResult> 

Implements: AdapterContract <APIGatewayProxyEvent, Context, APIGatewayProxyResult>

Remarks

This adapter is not fully compatible with @ vendia/serverless-express, on @ vendia they filter transfer-encoding=chunked but we throw an exception.

Example

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

Event Reference

(constructor)

Default constructor

Signature:

constructor(options?: ApiGatewayV1Options | undefined);

Parameters

ParameterTypeDescription
optionsApiGatewayV1Options | undefined(Optional) The options to customize the ApiGatewayV1Adapter

(method) canHandle

Signature:

canHandle(event: unknown): event is APIGatewayProxyEvent;

Parameters

ParameterTypeDescription
eventunknown

Returns:

event is APIGatewayProxyEvent

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: APIGatewayProxyEvent): string;

Parameters

ParameterTypeDescription
eventAPIGatewayProxyEventThe event sent by serverless

Returns:

string

(method) getRequest

Signature:

getRequest(event: APIGatewayProxyEvent): AdapterRequest;

Parameters

ParameterTypeDescription
eventAPIGatewayProxyEvent

Returns:

AdapterRequest

(method) getResponse

Signature:

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

Parameters

ParameterTypeDescription
{ headers: responseHeaders, body, isBase64Encoded, statusCode, response, }GetResponseAdapterProps <APIGatewayProxyEvent>

Returns:

APIGatewayProxyResult

(method) onErrorWhileForwarding

Signature:

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

Parameters

ParameterTypeDescription
{ error, delegatedResolver, respondWithErrors, event, log, }OnErrorProps <APIGatewayProxyEvent, APIGatewayProxyResult>

Returns:

void

(property) options

Signature:

protected readonly options?: ApiGatewayV1Options | undefined;

(property) stripPathFn

Strip base path function

Signature:

protected stripPathFn: StripBasePathFn;