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.
cloudwatch-metrics: Hydrates lambda's
context.metricsproperty with an instance of AWS MetricLogger
do-not-wait-for-empty-event-loop: Sets callbackWaitsForEmptyEventLoop property to false
error-logger: Logs errors
input-output-logger: Logs request and response
warmup: Used to pre-warm a lambda function
event-normalizer: Middleware for iterating through an AWS event records, parsing and normalizing nested events.
Accept-*headers and provides utilities for content negotiation (charset, encoding, language and media type) for HTTP requests
http-event-normalizer: Normalizes HTTP events by adding an empty object for
pathParametersif they are missing.
http-header-normalizer: Normalizes HTTP header names to their canonical format
http-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 of
http-multipart-body-parser: Automatically parses HTTP requests with content type
multipart/form-dataand 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.
http-content-encoding: Sets HTTP Content-Encoding header on response and compresses response body
http-cors: Sets HTTP CORS headers on response
http-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.
rds-signer: Fetches token for connecting to RDS with IAM users.
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.