Skip to content

PengWang0316/LambdaMiddlewares

Repository files navigation

Lambda Middlewares

Several middlewares for Lambda functions.

Build Status Coverage Status

Dependencies requirement

This library is working with several other packages. The peer dependencies list:

  • If use flushMetrics

    • @kevinwang0316/cloudwatch
    • aws-sdk
    • aws-xray-sdk
  • If use verifyJWT

    • @kevinwang0316/jwt-verify
    • @kevinwang0316/log
  • If use sampleLogging

    • @kevinwang0316/log
  • If use initializeMongoDB

    • @kevinwang0316/mongodb-helper
    • mongodb
  • If use mongoSanitize

    • mongo-sanitize
  • If use initialMysqlPool

    • mysql
    • @kevinwang0316/mysql-helper

Please check your package.json file to make sure you have these packages or install them.

Installing

npm install --save @kevinwang0316/lambda-middlewares

Usage

const middy = require('middy');
// Import the middlewares you want from different files
const { verifyJWT } = require('@kevinwang0316/lambda-middlewares/jwt');
const { initialMysqlPool } = require('@kevinwang0316/lambda-middlewares/mysql');
const { flushMetrics, sampleLogging, verifyJWT } = require('@kevinwang0316/lambda-middlewares');
const { initializeMongoDB, mongoSanitize } = require('@kevinwang0316/lambda-middlewares/mongodb');
// Here is your Lambda handler
const lambdaHandler = (event, context, callback) => {};

// You also can make a wrapper to add most common use
module.exports = middy(lambdaHandler)
  .use(sampleLogging())
  .use(mongoSanitize)
  .use(initializeMongodb)
  .use(verifyUser)
  .use(flushMetrics)
  .use(sampleLogging)
  .use(initialMysqlPool);

License

LambdaMiddlewares is licensed under MIT License - see the License file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published