랭킹으로 돌아가기

middyjs/middy

JavaScriptmiddy.js.org

🛵 The stylish Node.js middleware engine for AWS Lambda 🛵

serverlessawsaws-lambdaframeworkmiddlewarelambda-handlerlambdanodejsjavascripttypescriptmiddynode
스타 성장
스타
3.9k
포크
399
주간 성장
이슈
4
1k2k3k
2017년 8월2020년 7월2023년 7월2026년 7월
아티팩트npmnpm install middy
README
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.

관련 저장소
anuraghazra/github-readme-stats

:zap: Dynamically generated stats for your github readmes

JavaScriptnpmMIT Licenseprofile-readmedynamic
github-readme-stats.vercel.app
79.8k35.5k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
serverless/serverless

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.

JavaScriptnpmOtherserverlessserverless-framework
serverless.com
46.9k5.7k
Kong/kong

🦍 The API and AI Gateway

LuaApache License 2.0api-gatewaymicroservices
konghq.com/install/
43.8k5.2k
pingcap/tidb

TiDB is built for agentic workloads that grow unpredictably, with ACID guarantees and native support for transactions, analytics, and vector search. No data silos. No noisy neighbors. No infrastructure ceiling.

GoGo ModulesApache License 2.0distributed-databasedistributed-transactions
tidb.io
40.3k6.2k
firecracker-microvm/firecracker

Secure and fast microVMs for serverless computing.

Rustcrates.ioApache License 2.0virtual-machinesandbox
firecracker-microvm.io
35.6k2.5k
surrealdb/surrealdb

A scalable, distributed, collaborative, document-graph database, for the realtime web

Rustcrates.ioOtherdatabasedistributed
surrealdb.com
32.7k1.3k
openfaas/faas

OpenFaaS - Serverless Functions Made Simple

GoGo ModulesOtherfunctions-as-a-servicefunctions
openfaas.com
26.2k2k
dapr/dapr

Dapr is a portable runtime for building distributed applications across cloud and edge, combining event-driven architecture with workflow orchestration.

GoGo ModulesApache License 2.0microservicesmicroservice
dapr.io
26k2.1k
pulumi/pulumi

Pulumi - Infrastructure as Code in any programming language 🚀

GoGo ModulesApache License 2.0infrastructure-as-codeserverless
pulumi.com
25.5k1.4k
neondatabase/neon

Neon: Serverless Postgres. We separated storage and compute to offer autoscaling, code-like database branching, and scale to zero.

Rustcrates.ioApache License 2.0postgrespostgresql
neon.tech
22.6k1k
alibaba/ice

🚀 ice.js: The Progressive App Framework Based On React(基于 React 的渐进式应用框架)

TypeScriptnpmMIT Licensereactreact-router
ice.work
18.6k2.1k