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.

Observability

Lifecycle

Request Transformation

  • event-normalizer: Middleware for iterating through an AWS event records, parsing and normalizing nested events.
  • http-content-negotiation: Parses 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 queryStringParameters, multiValueQueryStringParameters or pathParameters if 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 httpErrorHandler.
  • http-jwt: Verifies a JWT on incoming HTTP requests using a shared secret or a public key fetched from kms.
  • http-multipart-body-parser: Automatically parses HTTP requests with content type multipart/form-data and converts the body into an object.
  • http-paseto: Verifies a PASETO v4.public token on incoming HTTP requests using a public key fetched from kms.
  • 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

Fetch Data

Lambda Extensions

AWS Lambda Extensions run as sidecar processes inside the Lambda execution environment and expose a local HTTP API. Middleware in this category talk to that local API instead of calling AWS service endpoints directly, trading AWS SDK overhead for a Lambda Layer dependency.

Incompatible with AWS Lambda Code Signing. Extensions are deployed as AWS-published Lambda Layers. If your function restricts layers to your own signing profiles, use the SDK-direct alternatives in the Fetch Data section instead.

  • appconfig-extension: Fetch AppConfig feature flags and configuration via the AppConfig Lambda Extension. Alternative to appconfig.
  • secrets-manager-extension: Fetch Secrets Manager secrets via the Parameters and Secrets Lambda Extension. Alternative to secrets-manager.
  • ssm-extension: Fetch SSM Parameter Store values via the Parameters and Secrets Lambda Extension. Alternative to ssm.

Last updated: