Several middlewares for Lambda functions.
This library is working with several other packages. The peer dependencies list:
-
- @kevinwang0316/cloudwatch
- aws-sdk
- aws-xray-sdk
-
- @kevinwang0316/jwt-verify
- @kevinwang0316/log
-
- @kevinwang0316/log
-
- @kevinwang0316/mongodb-helper
- mongodb
-
- mongo-sanitize
-
- mysql
- @kevinwang0316/mysql-helper
Please check your package.json file to make sure you have these packages or install them.
npm install --save @kevinwang0316/lambda-middlewares
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);
LambdaMiddlewares is licensed under MIT License - see the License file.