LAMBD
Create and maintain your AWS Lambdas or Google Cloud Functions functions easily with LAMBD!
How to install
npm i -S lambd
Getting started
How does I select platform?
const Lambd = ;const Platforms = Lambd; const myLambdaFunction = { // Here your lambda code response;}); // AWS Lambdas by default:// Lambd.create() // Google Cloud Functions// Lambd.createFunctions() // Otherwise// You can use Platform enum object and select platformmoduleexportsmyFunction = LambdplatformPlatformsGCLOUD; // This allows you make compatible all your lambdas between AWS and GCLOUD Functions platforms only you must change platform on code.
Simply example
const Lambd = ; const myLambdaFunction = { // Here your functions code response;}); moduleexportshandler = Lambd;
API example
const Lambd = ; const myLambda = Lambd; // Middlewaresconst authMiddleware = { const request response = options; const auth = request; if auth && auth === 'esto_es_una_prueba' ; else responsestatus403; }; const mongoMiddleware = { const response = options; const url = 'mongodb://localhost:27017/myproject'; MongoClient;}; myLambda;myLambda; // Route: /users/:useridconst handler = myLamba ; moduleexportshandler = handler;
Advanced example
LAMBD allows you use middlewares to add power to your lambda function.
const Lambd = ;const MongoClient = ; const myLambdaFunction = { // Here your lambda code db;}); const mongoMiddleware = { const response = options; const url = 'mongodb://localhost:27017/myproject'; MongoClient;}; // Global Middleware// Lambd.use(mongoMiddleware); // Lambda Middlewareconst myLambda = Lambd;myLambda; // Set headers to all lambdas// Lambd.set('MyFirstHeader', 'value');// Lambd.set({ 'MySecondHeader': 'value2', 'MyThirdHeader': 'value3' }); // Lambda headermyLambda;myLambda; moduleexportshandler = myLambda;