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
Parameter | Type | Description |
---|---|---|
options | AwsStreamHandlerOptions | 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
Parameter | Type | Description |
---|---|---|
app | TApp | The instance of the app (express, hapi, etc...) |
framework | FrameworkContract <TApp> | The framework that will process requests |
event | APIGatewayProxyEventV2 | The event sent by serverless |
context | The context sent by serverless | |
adapter | AdapterContract <APIGatewayProxyEventV2, AWSStreamContext , AWSStreamResponseMetadata > | The adapter resolved to this event |
_binarySettings | The binary settings | |
log | The 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
Parameter | Type | Description |
---|---|---|
app | TApp | |
framework | FrameworkContract <TApp> | |
adapters | AdapterContract <APIGatewayProxyEventV2, AWSStreamContext , AWSStreamResponseMetadata >[] | |
_resolverFactory | ResolverContract <unknown, unknown, unknown, unknown, unknown> | |
binarySettings | ||
respondWithErrors | boolean | |
log |
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
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
successResponse | The 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
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
event | APIGatewayProxyEventV2 | The event sent by serverless |
context | The context sent by serverless | |
binarySettings | The binary settings | |
respondWithErrors | boolean | Indicates 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
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
adapter | AdapterContract <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
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
requestValues | The request values returned by the adapter |
Returns:
void