AdapterContract
@h4ad/serverless-adapter > AdapterContract
(interface) AdapterContract
The interface that represents a contract between the adapter and the actual implementation of the adapter.
Signature:
export interface AdapterContract<TEvent, TContext, TResponse>
(method) canHandle
Decide if this adapter can handle a request based in the event payload
Signature:
canHandle(event: unknown, context: TContext, log: ILogger): boolean;
Parameters
Parameter | Type | Description |
---|---|---|
event | unknown | The event sent by serverless |
context | TContext | The context sent by the serverless |
log | ILogger | The instance of logger |
Returns:
boolean
(method) getAdapterName
Get the adapter name
Signature:
getAdapterName(): string;
Returns:
string
(method) getRequest
Maps the serverless payload to an actual request that a framework can handle
Signature:
getRequest(event: TEvent, context: TContext, log: ILogger): AdapterRequest;
Parameters
Parameter | Type | Description |
---|---|---|
event | TEvent | The event sent by serverless |
context | TContext | The context sent by the serverless |
log | ILogger | The instance of logger |
Returns:
(method) getResponse
Maps the response of the framework to a payload that serverless can handle
Signature:
getResponse(props: GetResponseAdapterProps<TEvent>): TResponse;
Parameters
Parameter | Type | Description |
---|---|---|
props | GetResponseAdapterProps <TEvent> | The props sent by serverless |
Returns:
TResponse
(method) onErrorWhileForwarding
When an error occurs while forwarding the request to the framework
Signature:
onErrorWhileForwarding(props: OnErrorProps<TEvent, TResponse>): void;
Parameters
Parameter | Type | Description |
---|---|---|
props | OnErrorProps <TEvent, TResponse> |
Returns:
void
Remarks
You must call resolver.fail or resolver.succeed when implementing this method.