Skip to main content

AlbAdapter

@h4ad/serverless-adapter > AlbAdapter

(class) AlbAdapter

The adapter to handle requests from AWS ALB

Signature:

export declare class AlbAdapter implements AdapterContract<ALBEvent, Context, ALBResult> 

Implements: AdapterContract <ALBEvent, Context, ALBResult>

Example

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

Event Reference

(constructor)

Default constructor

Signature:

constructor(options?: AlbAdapterOptions | undefined);

Parameters

ParameterTypeDescription
optionsAlbAdapterOptions | undefined(Optional) The options to customize the AlbAdapter

(method) canHandle

Signature:

canHandle(event: unknown): event is ALBEvent;

Parameters

ParameterTypeDescription
eventunknown

Returns:

event is ALBEvent

(method) getAdapterName

Signature:

getAdapterName(): string;

Returns:

string

(method) getPathFromEvent

Get path from event with query strings

Signature:

protected getPathFromEvent(event: ALBEvent): string;

Parameters

ParameterTypeDescription
eventALBEventThe event sent by serverless

Returns:

string

(method) getRequest

Signature:

getRequest(event: ALBEvent): AdapterRequest;

Parameters

ParameterTypeDescription
eventALBEvent

Returns:

AdapterRequest

(method) getResponse

Signature:

getResponse(\{ event, headers: responseHeaders, body, isBase64Encoded, statusCode, }: GetResponseAdapterProps<ALBEvent>): ALBResult;

Parameters

ParameterTypeDescription
{ event, headers: responseHeaders, body, isBase64Encoded, statusCode, }GetResponseAdapterProps <ALBEvent>

Returns:

ALBResult

(method) onErrorWhileForwarding

Signature:

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

Parameters

ParameterTypeDescription
{ error, delegatedResolver, respondWithErrors, event, log, }OnErrorProps <ALBEvent, ALBResult>

Returns:

void

(property) options

Signature:

protected readonly options?: AlbAdapterOptions | undefined;

(property) stripPathFn

Strip base path function

Signature:

protected stripPathFn: StripBasePathFn;