Introduction
(package) serverless-adapter
Classes
Class | Description |
---|---|
AlbAdapter | The adapter to handle requests from AWS ALB |
ApiGatewayV1Adapter | The adapter to handle requests from AWS Api Gateway V1 As per know issues , we throw an exception when you send the |
ApiGatewayV2Adapter | The adapter to handle requests from AWS Api Gateway V2 As per know issues , we throw an exception when you send the |
ApolloServerFramework | The framework that forwards requests to Apollo Server |
ApolloServerMutationAdapter | The adapter that wraps another adapter to force a transformation of the event data as a mutation to Apollo Server be able to handle. |
AwsContextResolver | The class that implements the resolver by using the AWS Context object. |
AwsSimpleAdapter | The abstract adapter to use to implement other simple AWS adapters |
AwsStreamHandler | The class that implements a default serverless handler consisting of a function with event, context and callback parameters respectively |
AzureHandler | The class that implements a serverless handler for Azure Function. When you don't specify a custom logger, the logger is used instead. |
BaseBodyParserFramework | The base class used by other body-parser functions to parse a specific content-type |
BaseHandler | The abstract class that represents the base class for a handler |
BufferToJSObjectTransformer | The transformer that is responsible to transform buffer's input to javascript objects |
CallbackResolver | The class that implements the resolver using the callback function sent by serverless |
CorsFramework | The framework that handles cors for your api without relying on internals of the framework |
DefaultHandler | The class that implements a default serverless handler consisting of a function with event, context and callback parameters respectively |
DigitalOceanHandler | The class that implements a serverless handler for Digital Ocean Functions. |
DummyAdapter | The class that represents a dummy adapter that does nothing and can be used by the cloud that doesn't use adapters. |
DummyResolver | The class that represents a dummy resolver that does nothing and can be used by the cloud that doesn't use resolvers. |
DynamoDBAdapter | The adapter to handle requests from AWS DynamoDB. The option of |
EventBridgeAdapter | The adapter to handle requests from AWS EventBridge (Cloudwatch Events). The option of |
ExpressFramework | The framework that forwards requests to express handler |
FastifyFramework | The framework that forwards requests to fastify handler |
GCPHandler | The class that implements a handler for GCP Http Functions |
HapiFramework | The framework that forwards requests to hapi handler |
HttpDeepkitFramework | The framework that forwards requests to express handler |
HttpFirebaseHandler | The class that implements a handler for Firebase Https Events |
HttpFirebaseV2Handler | The class that implements a handler for Firebase Https Events |
HttpFunctionAdapter | The adapter to handle requests from Digital Ocean Functions when called from HTTP Endpoint. |
HttpHuaweiHandler | The class that implements a huawei serverless handler with http function that exposes a http server in specific port. In this Handler, you don't need to specific resolver and adapter, so you can use DummyAdapter and DummyResolver instead. |
HttpTriggerV4Adapter | The adapter to handle requests from Http Trigger on Azure Function V4. |
HuaweiApiGatewayAdapter | The adapter to handle requests from Huawei Api Gateway |
JsonBodyParserFramework | The body-parser class used to parse application/json. |
KoaFramework | The framework that forwards requests to koa handler |
LambdaEdgeAdapter | The adapter to handle requests from AWS Lambda @ Edge. This adapter is not fully compatible with Lambda @ edge supported by @ vendia/serverless-express, the request body was modified to return NewLambdaEdgeBody instead OldLambdaEdgeBody . Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of . And when we get an error during the forwarding to the framework, we call |
LazyFramework | The framework that asynchronously instantiates your application and forwards the request to the framework as quickly as possible. |
PolkaFramework | The framework that forwards requests to polka handler |
PromiseResolver | The class that implements the resolver using the promise object sent by this library |
RawBodyParserFramework | The body-parser class used to parse application/octet-stream. |
RawRequest | The class that expose some methods to be used to get raw request from Express HTTP Request |
RequestLambdaEdgeAdapter | The adapter to handle requests from AWS Lambda @ Edge of the type Viewer Request. The idea of this Adapter is to you be able to expose your framework to the Edge, like when you build for Cloudfront. |
S3Adapter | The adapter to handle requests from AWS S3. The option of |
ServerlessAdapter | The class used to build the serverless handler. |
ServerlessRequest | The class that represents an created by the library to represent an actual request to the framework. |
ServerlessResponse | The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request. Once it's happens, we use the properties from this response to built the response to the cloud. |
ServerlessStreamResponse | The class that represents a response instance used to send to the framework and wait until the framework finishes processing the request. This response is specially built to deal with transfer-encoding: chunked |
SNSAdapter | The adapter to handle requests from AWS SNS. The option of |
SQSAdapter | The adapter to handle requests from AWS SQS. The option of |
TextBodyParserFramework | The body-parser class used to parse text/plain. |
TrpcFramework | The framework that forwards requests to TRPC handler |
UrlencodedBodyParserFramework | The body-parser class used to parse application/x-www-form-urlencoded. |
Functions
Function | Description |
---|---|
buildStripBasePath(basePath) | Get the strip base path function |
createDefaultLogger({ level }) | The method used to create a simple logger instance to use in this library. |
getContentType(headers) | The function that returns the content type of headers |
getCurrentInvoke() | Get the reference to the event created by the serverless trigger or context created by the serverless environment. |
getDefaultIfUndefined(value, defaultValue) | Return the defaultValue whether the value is undefined, otherwise, return the value. |
getEventBodyAsBuffer(body, isBase64Encoded) | Get the event body as buffer from body string with content length |
getFlattenedHeadersMap(headersMap, separator, lowerCaseKey) | Transform a header map and make sure the value is not an array |
getFlattenedHeadersMapAndCookies(headersMap) | Transforms a header map into a single value headers and cookies |
getMultiValueHeadersMap(headersMap) | Transforms a header map into a multi-value map header. |
getPathWithQueryStringParams(path, queryParams) | Transform the path and a map of query params to a string with formatted query params |
getQueryParamsStringFromRecord(queryParamsRecord) | Map query params to a string with formatted query params |
getString(data) | Get the data from a buffer, string, or Uint8Array |
isBinary(headers, binarySettings) | The function used to determine from the headers and the binary settings if a response should be encoded or not |
isContentEncodingBinary(headers, binaryEncodingTypes) | The function that determines by the content encoding whether the response should be treated as binary |
isContentTypeBinary(headers, binaryContentTypes) | The function that determines by the content type whether the response should be treated as binary |
isInternalLogger(logger) | The method used to chck if logger was created by this library, or it was defined by the user. |
isStreamEnded(stream) | Check if stream already ended |
keysToLowercase(obj) | |
parseHeaders(headers) | Parse HTTP Raw Headers Attribution to https://github.com/kesla/parse-headers/blob/master/parse-headers.js |
setCurrentInvoke({ event, context, }) | Method that saves to the event created by the serverless trigger or context created by the serverless environment. |
waitForStreamComplete(stream) | Wait asynchronous the stream to complete |
Interfaces
Interface | Description |
---|---|
AdapterContract | The interface that represents a contract between the adapter and the actual implementation of the adapter. |
AdapterRequest | The request interface used to bridge any event source to the framework. |
AlbAdapterOptions | The options to customize the AlbAdapter |
ApiGatewayV1Options | The options to customize the ApiGatewayV1Adapter |
ApiGatewayV2Options | The options to customize the ApiGatewayV2Adapter |
ApolloServerOptions | The options to customize ApolloServerFramework |
AWSSimpleAdapterOptions | The options to customize the AwsSimpleAdapter |
AzureHandlerOptions | The options to customize AzureHandler |
BinarySettingsContentHeaders | The interface representing the binary settings implementation by looking inside the headers |
BinarySettingsFunction | The interface representing the binary settings implementation by function |
DefaultServerlessApolloServerContext | The default context of Apollo Server when you integrate and don't pass any context. |
DynamoDBAdapterOptions | The options to customize the DynamoDBAdapter |
EventBridgeOptions | The options to customize the EventBridgeAdapter |
FrameworkContract | The interface that represents a contract between the framework and the framework implementation |
GetResponseAdapterProps | The props of the method that get the response from the framework and transform it into a format that the event source can handle |
HandlerContract | The interface that represents the contract between the handler and the real implementation |
HttpFunctionAdapterOptions | The options to customize the HttpFunctionAdapter |
HttpTriggerV4AdapterOptions | The options to customize the HttpTriggerV4Adapter |
HuaweiApiGatewayEvent | The interface that represents the Api Gateway Event of Huawei when integrate with Function Graph of Event Type. See more in Reference . |
HuaweiApiGatewayOptions | The options to customize the HuaweiApiGatewayAdapter |
HuaweiApiGatewayResponse | The interface that represents the Api Gateway Response of Huawei when integrate with Function Graph of Event Type. See more in Reference . |
HuaweiContext | The interface that represents methods sent by huawei to get information about the function graph. See more in Context Methods |
HuaweiRequestContext | The interface that represents the values you can get inside request context. |
LambdaEdgeAdapterOptions | The options to customize the LambdaEdgeAdapter . |
OnErrorProps | The props of the method that handle the response when an error occurs while forwarding the request to the framework |
RequestLambdaEdgeAdapterOptions | The options to customize the RequestLambdaEdgeAdapter . |
ResolverContract | The interface that represents the contract used to send the response to the client |
S3AdapterOptions | The options to customize the S3Adapter |
ServerlessRequestProps | The properties to create a ServerlessRequest |
ServerlessResponseProps | The properties to create a ServerlessResponse . |
ServerlessStreamResponseProps | The properties to create a ServerlessStreamResponse . |
SNSAdapterOptions | The options to customize the SNSAdapter |
SQSAdapterOptions | The options to customize the SQSAdapter |
TrpcAdapterBaseContext | The context created by this library that allows getting some information from the request and setting the status and header of the response. |
Variables
Variable | Description |
---|---|
DEFAULT_BINARY_CONTENT_TYPES | Default content types that are treated as binary, they are compared with the Content-Type header. |
DEFAULT_BINARY_ENCODINGS | Default encodings that are treated as binary, they are compared with the Content-Encoding header. |
DEFAULT_HUAWEI_LISTEN_PORT | The default port that huawei will proxy the request to your framework |
DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS | The list was created based on these docs in the "Disallowed Headers" section. |
DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES | The default max response size in bytes of origin request and origin response. |
DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES | The default max response size in bytes of viewer request and viewer response. |
EmptyResponse | Constant for empty response and can be used on some adapters when the adapter does not need to return a response. |
NO_OP | No operation function is used when we need to pass a function, but we don't want to specify any behavior. |
Type Aliases
Type Alias | Description |
---|---|
ApolloServerContextArguments | The arguments used to create a Context inside ApolloServerOptions |
ApolloServerMutationAdapterOptions | The options for ApolloServerMutationAdapter |
AWSResponseStream | |
AWSSimpleAdapterResponseType | The possible options of response for AwsSimpleAdapter |
AWSStreamContext | The interface that describes the internal context used by the AwsStreamHandler |
AwsStreamHandlerOptions | The interface that customizes the AwsStreamHandler |
AWSStreamResponseMetadata | |
BatchItemFailureResponse | The batch item failure response expected from the API server |
BinarySettings | The interface representing the settings for whether the response should be treated as binary or not |
BodyParserOptions | The options for BaseBodyParserFramework |
BothValueHeaders | The record that represents the headers that can both single or multiple values in the value |
Concrete | Removes 'optional' attributes from a type's properties |
CorsFrameworkOptions | The options to customize CorsFramework |
CurrentInvoke | The type that represents the object that handles the references to the event created by the serverless trigger or context created by the serverless environment. |
DefaultForwardPath | The type alias to indicate where we get the default value of path to create the request. |
DefaultQueryString | The type alias to indicate where we get the default value of query string to create the request. |
DelegatedResolver | The type that represents a delegate resolver that is passed to the adapter to handle what to do when an error occurs during forwarding. |
EventBridgeEventAll | Just a type alias to ignore generic types in the event |
FirebaseHttpHandler | The HTTP handler that is exposed when you use HttpFirebaseV2Handler . |
FlattenedHeadersAndCookies | The wrapper that holds the information about single value headers and cookies |
GetAccessKeyReturn | The return value of HuaweiContext getAccessKey |
GetCPUNumberReturn | The return value of HuaweiContext getCPUNumber |
GetFunctionNameReturn | The return value of HuaweiContext getFunctionName |
GetLoggerReturn | The return value of HuaweiContext getLogger Is the instance of logger that can be used to send logs to |
GetMemorySizeReturn | The return value of HuaweiContext getMemorySize |
GetPackageReturn | The return value of HuaweiContext getPackage |
GetProjectIdReturn | The return value of HuaweiContext getProjectID |
GetRemainingTimeInMilliSecondsReturn | The return value of HuaweiContext getRemainingTimeInMilliSeconds |
GetRequestIDSecondsReturn | The return value of HuaweiContext getRequestID |
GetRunningTimeInSecondsReturn | The return value of HuaweiContext getRunningTimeInSeconds |
GetSecretKeyReturn | The return value of HuaweiContext getSecretKey |
GetTokenReturn | The return value of HuaweiContext getToken |
GetUserDataKeyParameter | The parameters of the method HuaweiContext getUserData |
GetUserDataReturn | The return value of HuaweiContext getUserData |
GetVersionReturn | The return value of HuaweiContext getVersion |
HttpHuaweiHandlerOptions | The options to customize HttpHuaweiHandler |
HuaweiRequestPathParameters | The path parameters of the request, usually is the name of the wildcard you create in FunctionGraph, such as / { proxy } . |
HuaweiRequestQueryStringParameters | The query strings of the request |
IEmptyResponse | Type alias for empty response and can be used on some adapters when the adapter does not need to return a response. |
ILogger | The interface representing the logger, you can provide a custom logger by implementing this interface. |
JsonBodyParserFrameworkOptions | The body-parser options for application/json |
LoggerFN | The log function used in any level. |
LoggerOptions | The options to customize ILogger |
LogLevels | The type representing the possible log levels to choose from. |
MultiValueHeaders | The record that represents the headers that have multiple values in the value |
NewLambdaEdgeBody | Represents the body of the new version of Lambda @ edge, which uses the body property inside request as the body (library) of the request. |
OldLambdaEdgeBody | Represents the body of the old version of Lambda @ edge supported by @ vendia/serverless-express which returns the data property within body for the body (library) of the request. |
RawBodyParserFrameworkOptions | The body-parser options for application/octet-stream |
Resolver | The type that represents a resolver used to send the response, error or success, to the client |
ResolverProps | The createResolver contract props |
ServerlessCallback | The default signature of the callback sent by serverless |
ServerlessHandler | The function used to handle serverless requests |
SingleValueHeaders | The record that represents the headers that doesn't have multiple values in the value |
StripBasePathFn | Type of the function to strip base path |
TextBodyParserFrameworkOptions | The body-parser options for text/plain |
TrpcAdapterContext | This is the context merged between TrpcAdapterBaseContext and the that you provided. This context will be merged with the context you created with |
TrpcFrameworkOptions | The options to customize the TrpcFramework |
UrlencodedBodyParserFrameworkOptions | The body parser options for application/x-www-form-urlencoded |