8000 GitHub - pambda/pambda: Pluggable Lambda for AWS
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pambda/pambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

License

MIT

About

Pluggable Lambda for AWS

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0