middy is a free, open source build & deployment project written in JavaScript and released under MIT. It has 3,904 GitHub stars, 399 forks and 9 open issues, and was last pushed 5 days ago. On this registry it ranks #36 of 59 tracked projects in Build & Deployment, with 5 head-to-head comparisons available.

What is middy?

What it is

Middy middleware engine AWS Lambda Node.js. Handler focus business logic. Attach reusable steps parsing, validation, auth, observability, error handling, AWS service integration. Ecosystem JavaScript TypeScript serverless. Official packages cover Lambda event sources and HTTP services. Project MIT licensed. Homepage middy.js.org. Docs cover getting started, official middlewares, event types, routers, custom middlewares, recipes, FAQ. GitHub metadata lists 3904 stars, 399 forks, 9 open issues, 9 year repo age, and last push 2026-09-12T15:33:46Z.

Middy solves repeated non-functional code in Lambda handlers. Production handlers need same input validation, structured logging, error mapping, secret retrieval, CORS handling, response shaping, partial-batch failure logic. Teams compose middleware around one handler, not copy steps into every handler. README says use Middy for every production Lambda.

Key capabilities

  • 52 official packages cover API Gateway, SQS, S3, DynamoDB, SNS, EventBridge, Kinesis, Kafka, WebSockets, and more.
  • Tiny core uses only @middy/util, plus optional peer dependency for durable functions, and no AWS SDK in core.
  • Built-in TypeScript types, Node.js >= 22, ESM.
  • Routers for HTTP, WebSocket, CloudFormation custom resources.
  • First-class support AWS Lambda response streaming and durable functions.
  • README example uses @middy/http-json-body-parser, @middy/http-error-handler, @middy/validator.
  • Middleware supports input validation, structured logging, mapped HTTP errors, secrets and config with caching and cold-start prefetch, CORS, security headers, response shaping, authentication, partial-batch failure handling, graceful pre-timeout responses.

Who uses it and how

  • Serverless teams use Middy when AWS Lambda handlers validate HTTP bodies, headers, query parameters, event-source payloads at trust boundaries.
  • API teams attach authentication, CORS, security headers, mapped HTTP error responses around business logic handler.
  • Event-driven teams use SQS, Kinesis, DynamoDB Streams, Kafka, S3 Batch workflows needing partial-batch failure handling.
  • Operations teams add structured logging, consistent error reporting, secrets retrieval, cold-start prefetch to production Lambda functions.
  • Framework builders use Middy routers for HTTP, WebSocket, CloudFormation custom resource handlers instead of separate dispatch code.

Getting started

Install @middy/core with npm, then add only needed middleware packages, such as @middy/http-json-body-parser, @middy/http-error-handler, @middy/validator. No Docker image or hosted option mentioned.

When to use it โ€” and when not to

Middy fits production AWS Lambda handlers on Node.js needing reusable validation, logging, error mapping, auth, event-source handling. Less suitable projects not AWS Lambda, or teams wanting single handler without middleware composition. Tiny core means teams select and maintain extra packages for AWS service integration and optional durable functions.

project readme (upstream, from github) โ€” read inline
Middy logo

The stylish Node.js middleware engine for AWS Lambda

GitHub Actions unit test status GitHub Actions dast test status GitHub Actions perf test status GitHub Actions SAST test status GitHub Actions lint test status
npm version npm install size npm weekly downloads npm provenance
Open Source Security Foundation (OpenSSF) Scorecard SLSA 3 Checked with Biome Conventional Commits code coverage

Full documentation: https://middy.js.org · LLM-friendly: llms.txt / llms-full.txt

What is Middy

Middy is a middleware engine for AWS Lambda on Node.js. It lets you keep your handler focused on business logic while attaching reusable steps for parsing, validation, auth, observability, error handling, and AWS service integration.

  • 52 official packages covering API Gateway, SQS, S3, DynamoDB, SNS, EventBridge, Kinesis, Kafka, WebSockets, and more
  • Built-in TypeScript types, Node.js >= 22, ESM
  • Tiny core (only @middy/util, plus an optional peer dependency for durable functions), no AWS SDK in core
  • Routers for HTTP, WebSocket, and CloudFormation custom resources
  • First-class support for AWS Lambda response streaming and durable functions

Install

npm install --save @middy/core
# add only the middlewares you need
npm install --save @middy/http-json-body-parser @middy/http-error-handler @middy/validator

Example

import middy from '@middy/core'
import httpJsonBodyParser from '@middy/http-json-body-parser'
import httpErrorHandler from '@middy/http-error-handler'
import validator from '@middy/validator'
import { transpileSchema } from '@middy/validator/transpile'

const schema = {
  type: 'object',
  properties: {
    body: {
      type: 'object',
      properties: {
        amount: { type: 'number' },
        currency: { type: 'string' }
      },
      required: ['amount', 'currency']
    }
  }
}

const lambdaHandler = async (event) => {
  const { amount, currency } = event.body
  // ... business logic
  return { statusCode: 200, body: JSON.stringify({ ok: true, amount, currency }) }
}

export const handler = middy()
  .use(httpJsonBodyParser())
  .use(validator({ eventSchema: transpileSchema(schema) }))
  .use(httpErrorHandler())
  .handler(lambdaHandler)

When to use Middy

Use Middy for every production Lambda. Production handlers always need the same set of non-functional concerns:

  • Input validation at every trust boundary (HTTP body / headers / query, event-source payloads).
  • Structured logging and consistent error reporting.
  • Mapped HTTP error responses instead of stack traces.
  • Secrets and config fetched from a secure store with caching + cold-start prefetch.
  • CORS, security headers, response shaping for HTTP APIs.
  • Authentication for anything exposed to the internet.
  • Partial-batch failure handling for SQS / Kinesis / DynamoDB Streams / Kafka / S3 Batch.
  • Graceful pre-timeout responses so clients see 408, not 504.

Middy is how you compose those without copy-pasting them into every handler. The "tiny single handler" exception is a trap - production handlers grow, and you do not want to add validation and error mapping under pressure later.

See When to use Middy, Middy vs raw Lambda, and Middy + AWS Lambda Powertools.

Documentation

Sponsors

fourTheorem Amazon Web Services Free and Open Source Software Fund (AWS FOSS Fund)

License

Licensed under MIT License. Copyright (c) 2017-2026 will Farrell, Luciano Mammino, and Middy contributors.

Frequently asked questions

Is middy free to use?

middy is open source under the MIT licence. There is no licence fee and no seat count โ€” you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does middy do?

๐Ÿ›ต The stylish Node.js middleware engine for AWS Lambda ๐Ÿ›ต

What is middy written in?

middy is primarily written in JavaScript. Its source is publicly available at https://github.com/middyjs/middy, and it has 3,904 GitHub stars.