Official middlewares
Middy comes with a series of additional (opt-in) plugins that are officially maintained by the core team and kept in sync with every release of the core package.
These middleware focus on common use cases when using Lambda with other AWS services.
Each middleware should do a single task. We try to balance each to be as performant as possible while meeting the majority of developer needs.
Misc
cloudwatch-metrics
: Hydrates lambda'scontext.metrics
property with an instance of AWS MetricLoggerdo-not-wait-for-empty-event-loop
: Sets callbackWaitsForEmptyEventLoop property to falseerror-logger
: Logs errorsinput-output-logger
: Logs request and responsewarmup
: Used to pre-warm a lambda function
Request Transformation
event-normalizer
: Middleware for iterating through an AWS event records, parsing and normalizing nested events.http-content-negotiation
: ParsesAccept-*
headers and provides utilities for content negotiation (charset, encoding, language and media type) for HTTP requestshttp-event-normalizer
: Normalizes HTTP events by adding an empty object forqueryStringParameters
,multiValueQueryStringParameters
orpathParameters
if they are missing.http-header-normalizer
: Normalizes HTTP header names to their canonical formathttp-json-body-parser
: Automatically parses HTTP requests with JSON body and converts the body into an object. Also handles gracefully broken JSON if used in combination ofhttpErrorHandler
.http-multipart-body-parser
: Automatically parses HTTP requests with content typemultipart/form-data
and converts the body into an object.http-urlencode-body-parser
: Automatically parses HTTP requests with URL encoded body (typically the result of a form submit).http-urlencode-path-parser
: Automatically parses HTTP requests with URL encoded path.validator
: Automatically validates incoming events and outgoing responses against custom schemas.ws-json-body-parser
: Automatically parses WebSocket requests with JSON message and converts the message into an object.
Response Transformation
http-content-encoding
: Sets HTTP Content-Encoding header on response and compresses response bodyhttp-cors
: Sets HTTP CORS headers on responsehttp-error-handler
: Creates a proper HTTP response for errors that are created with the http-errors module and represents proper HTTP errors.http-security-headers
: Applies best practice security headers to responses. It's a simplified port of HelmetJS.http-partial-response
: Filter response objects attributes based on query string parameters.http-response-serializer
: HTTP response serializer.sqs-partial-batch-failure
: Handles partially failed SQS batches.ws-response
: Forwards response to WebSocket endpoint.
Fetch Data
appconfig
: Fetch JSON configurations from AppConfig.dynamodb
: Fetch configurations from DynamoDB.rds-signer
: Fetches token for connecting to RDS with IAM users.s3
: Fetch JSON configurations from S3.s3-object-response
: Gets and write S3 object response.secrets-manager
: Fetches parameters from AWS Secrets Manager.service-discovery
: Fetches Service Discovery instances to be used when connecting to other AWS services.ssm
: Fetches parameters from AWS Systems Manager Parameter Store.sts
: Fetches credentials to assumes IAM roles for connection to other AWS services.