pambda
Pluggable Lambda for AWS.
Usage
By using this package, you can define a Lambda handler in function synthesis as follows:
const { compose, createLambda } = require('pambda');
exports.handler = createLambda(
compose(
pambda1,
pambda2,
...
)
);
Definition
Pambda
type Pambda = (next: Lambda) => Lambda
This function returns Lambda. It specifies the Lambda that Lambda should call next by argument next
.
Since next
can specify Lambda to be executed next, one large Lambda can be divided into multiple smaller Lambdas.
Lambda
type Lambda = (event, context, callback) | (event, context) => Promise
Lambda supports both callback style functions and async functions.
When invoking Lambda in Pambda, it is necessary to make it work in both types of functions.
API
compose(...pambdas: Pambda[]): Pambda
Return a Pambda which synthesized specified Pambdas.
If you pass the last executed Lambda to the synthesized Pambda, the Lambda of the Pambda specified by the first argument is returned. By executing that Lambda, Lambda in Pambda is executed in the order specified by the arguments.
If there is an identity
pambda in the argument pambdas
, they are not to be composited.
Falsy values are also ignored. This is useful that a process depending on environment variables such as a following:
compose(
process.env.AWS_SAM_LOCAL === 'true' && localOnlyPambda,
...
)
createLambda(pambda: Pambda): Lambda
Return Lambda from the specified Pambda. The Lambda is exported and used as the main handler.
Pambda's argument next
is passed Lambda which returns an error.
This function passes lambda-terminator to argument next in the passed pambda.
The execution of lambda-terminator
means there is a bug in the pambda.
identity: Pambda
This pambda do nothing.
Context Extending
Some pambdas add properties into a context. Adding properties are following:
Property | Pambda |
---|---|
[AWSService] | pambda-aws |
logEvent | pambda-cwlogs |
redirect | pambda-redirect |
render | pambda-pug |
Event Extending
Property | Pambda |
---|---|
cookies | pambda-cookie |
Related
- create-pambda-app
- pambda-404
- pambda-aws
- pambda-binary-support
- pambda-by-env
- pambda-cache
- pambda-cookie
- pambda-cwlogs
- pambda-env
- pambda-errorhandler
- pambda-github-fetch
- pambda-headers
- pambda-json-api
- pambda-jwt-authorizer
- pambda-logger
- pambda-path
- pambda-pug
- pambda-records
- pambda-redirect
- pambda-redux
- pambda-router
- pambda-s3-fetch
- pambda-serve-static
- pambda-tap
- pambda-terminator
License
MIT