Skip to main content

AwsStreamHandler

@h4ad/serverless-adapter > AwsStreamHandler

(class) AwsStreamHandler

The class that implements a default serverless handler consisting of a function with event, context and callback parameters respectively

Signature:

export declare class AwsStreamHandler<TApp> extends BaseHandler<TApp, APIGatewayProxyEventV2, AWSStreamContext, void, AWSStreamResponseMetadata, void> 

Extends: BaseHandler <TApp, APIGatewayProxyEventV2, AWSStreamContext , void, AWSStreamResponseMetadata , void>

(constructor)

Construtor padrão

Signature:

constructor(options?: AwsStreamHandlerOptions | undefined);

Parameters

ParameterTypeDescription
optionsAwsStreamHandlerOptions | undefined(Optional)

(method) forwardRequestToFramework

The function to forward the event to the framework

Signature:

protected forwardRequestToFramework(app: TApp, framework: FrameworkContract<TApp>, event: APIGatewayProxyEventV2, context: AWSStreamContext, adapter: AdapterContract<APIGatewayProxyEventV2, AWSStreamContext, AWSStreamResponseMetadata>, _binarySettings: BinarySettings, log: ILogger): Promise<void>;

Parameters

ParameterTypeDescription
appTAppThe instance of the app (express, hapi, etc...)
frameworkFrameworkContract <TApp>The framework that will process requests
eventAPIGatewayProxyEventV2The event sent by serverless
contextAWSStreamContextThe context sent by serverless
adapterAdapterContract <APIGatewayProxyEventV2, AWSStreamContext , AWSStreamResponseMetadata >The adapter resolved to this event
_binarySettingsBinarySettingsThe binary settings
logILoggerThe instance of logger

Returns:

Promise<void>

(method) getHandler

Signature:

getHandler(app: TApp, framework: FrameworkContract<TApp>, adapters: AdapterContract<APIGatewayProxyEventV2, AWSStreamContext, AWSStreamResponseMetadata>[], _resolverFactory: ResolverContract<unknown, unknown, unknown, unknown, unknown>, binarySettings: BinarySettings, respondWithErrors: boolean, log: ILogger): ServerlessHandler<Promise<void>>;

Parameters

ParameterTypeDescription
appTApp
frameworkFrameworkContract <TApp>
adaptersAdapterContract <APIGatewayProxyEventV2, AWSStreamContext , AWSStreamResponseMetadata >[]
_resolverFactoryResolverContract <unknown, unknown, unknown, unknown, unknown>
binarySettingsBinarySettings
respondWithErrorsboolean
logILogger

Returns:

ServerlessHandler <Promise<void>>

(method) onForwardResponseAdapterResponse

The hook executed before sending response to the serverless with response from adapter

Signature:

protected onForwardResponseAdapterResponse(log: ILogger, successResponse: AWSStreamResponseMetadata): void;

Parameters

ParameterTypeDescription
logILoggerThe instance of logger
successResponseAWSStreamResponseMetadataThe success response resolved by the adapter

Returns:

void

(method) onReceiveRequest

The hook executed on receive a request, before the request is being processed

Signature:

protected onReceiveRequest(log: ILogger, event: APIGatewayProxyEventV2, context: AWSStreamContext, binarySettings: BinarySettings, respondWithErrors: boolean): void;

Parameters

ParameterTypeDescription
logILoggerThe instance of logger
eventAPIGatewayProxyEventV2The event sent by serverless
contextAWSStreamContextThe context sent by serverless
binarySettingsBinarySettingsThe binary settings
respondWithErrorsbooleanIndicates whether the error stack should be included in the response or not

Returns:

void

(method) onResolveAdapter

The hook executed after resolve the adapter that will be used to handle the request and response

Signature:

protected onResolveAdapter(log: ILogger, adapter: AdapterContract<APIGatewayProxyEventV2, AWSStreamContext, AWSStreamResponseMetadata>): void;

Parameters

ParameterTypeDescription
logILoggerThe instance of logger
adapterAdapterContract <APIGatewayProxyEventV2, AWSStreamContext , AWSStreamResponseMetadata >The adapter resolved

Returns:

void

(method) onResolveRequestValues

The hook executed after resolves the request values that will be sent to the framework

Signature:

protected onResolveRequestValues(log: ILogger, requestValues: AdapterRequest): void;

Parameters

ParameterTypeDescription
logILoggerThe instance of logger
requestValuesAdapterRequestThe request values returned by the adapter

Returns:

void