DefaultHandler
@h4ad/serverless-adapter > DefaultHandler
(class) DefaultHandler
The class that implements a default serverless handler consisting of a function with event, context and callback parameters respectively
Signature:
export declare class DefaultHandler<TApp, TEvent, TContext, TCallback, TResponse, TReturn> extends BaseHandler<TApp, TEvent, TContext, TCallback, TResponse, TReturn>
Extends: BaseHandler <TApp, TEvent, TContext, TCallback, TResponse, TReturn>
(method) forwardRequestToFramework
The function to forward the event to the framework
Signature:
protected forwardRequestToFramework(app: TApp, framework: FrameworkContract<TApp>, event: TEvent, context: TContext, adapter: AdapterContract<TEvent, TContext, TResponse>, binarySettings: BinarySettings, log: ILogger): Promise<TResponse>;
Parameters
Parameter | Type | Description |
---|---|---|
app | TApp | The instance of the app (express, hapi, etc...) |
framework | FrameworkContract <TApp> | The framework that will process requests |
event | TEvent | The event sent by serverless |
context | TContext | The context sent by serverless |
adapter | AdapterContract <TEvent, TContext, TResponse> | The adapter resolved to this event |
binarySettings | The binary settings | |
log | The instance of logger |
Returns:
Promise<TResponse>
(method) forwardResponse
The function to forward the response back to the serverless
Signature:
protected forwardResponse(event: TEvent, response: ServerlessResponse, adapter: AdapterContract<TEvent, TContext, TResponse>, binarySettings: BinarySettings, log: ILogger): TResponse;
Parameters
Parameter | Type | Description |
---|---|---|
event | TEvent | The event sent by serverless |
response | The response of the framework | |
adapter | AdapterContract <TEvent, TContext, TResponse> | The adapter resolved to this event |
binarySettings | The binary settings | |
log | The instance of logger |
Returns:
TResponse
(method) getHandler
Signature:
getHandler(app: TApp, framework: FrameworkContract<TApp>, adapters: AdapterContract<TEvent, TContext, TResponse>[], resolverFactory: ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn>, binarySettings: BinarySettings, respondWithErrors: boolean, log: ILogger): ServerlessHandler<TReturn>;
Parameters
Parameter | Type | Description |
---|---|---|
app | TApp | |
framework | FrameworkContract <TApp> | |
adapters | AdapterContract <TEvent, TContext, TResponse>[] | |
resolverFactory | ResolverContract <TEvent, TContext, TCallback, TResponse, TReturn> | |
binarySettings | ||
respondWithErrors | boolean | |
log |
Returns:
ServerlessHandler <TReturn>
(method) onForwardResponse
The hook executed before sending response to the serverless
Signature:
protected onForwardResponse(log: ILogger, statusCode: number, body: string, headers: SingleValueHeaders, isBase64Encoded: boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
statusCode | number | The status code of the response |
body | string | The body of the response |
headers | The headers of the response | |
isBase64Encoded | boolean | Indicates whether the response was encoded as binary or not |
Returns:
void
(method) onForwardResponseAdapterResponse
The hook executed before sending response to the serverless with response from adapter
Signature:
protected onForwardResponseAdapterResponse(log: ILogger, successResponse: TResponse, body: string): void;
Parameters
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
successResponse | TResponse | The success response resolved by the adapter |
body | string | The body of the response sent by the framework |
Returns:
void
(method) onReceiveRequest
The hook executed on receive a request, before the request is being processed
Signature:
protected onReceiveRequest(log: ILogger, event: TEvent, context: TContext, binarySettings: BinarySettings, respondWithErrors: boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
event | TEvent | The event sent by serverless |
context | TContext | 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<TEvent, TContext, TResponse>): void;
Parameters
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
adapter | AdapterContract <TEvent, TContext, TResponse> | The adapter resolved |
Returns:
void
(method) onResolveForwardedResponseToFramework
The hook executed after handling the response sent by the framework
Signature:
protected onResolveForwardedResponseToFramework(log: ILogger, response: ServerlessResponse): void;
Parameters
Parameter | Type | Description |
---|---|---|
log | The instance of logger | |
response | The response sent by the framework |
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