lombda
v2.0.7
Published
Execute lambdas using express as api gateway
Downloads
188
Readme
Lombda
This is a POC that lets you simulate an api gateway lambda proxy integration using an alternative server framework. For the moment only Express.js is supported.
The library transforms the incoming request object to the payload that api gateway sends to the lambda when configured as Lambda Proxy Integration, more details can be found here. It also supports lambda authorizer.
Setup
Lombda requires that you define the routes that your lambdas will be mapped to. To start you must install lombda package.
npm i lombda
If you have environment variables
npm i dotenv
and create an .env
file with your variables
// lombda.js
const dotenv = require('dotenv');
const Lombda = require('lombda').default;
dotenv.config();
Lombda.express([
{
lambdaIndex: 'path/to/public/lambda/dist/index.js',
lambdaHandler: 'handler',
routeKey: 'POST /public-lambda',
},
{
lambdaIndex: 'path/to/authorized/lambda/index.js',
lambdaHandler: 'handler',
routeKey: 'GET /authorized-lambda',
authorizer: {
lambdaIndex: 'path/to/authorizer/dist/index.js',
lambdaHandler: 'handler',
},
},
], {
basePath: __dirname,
port: 3002,
});
To run it just execute
node lombda.js