Skip to content
reaatechREAATECH

reaatech/idempotency-middleware

0Last commit: Jun 4, 2026GitHub →

These packages give you idempotency middleware for POST, PUT, and PATCH requests — duplicate requests with the same `Idempotency-Key` header return the cached original response instead of re-executing side effects. You'd adopt them to safely retry payment charges, webhook deliveries, or any mutation where duplicate execution would cause data corruption or duplicate charges. The core provides a pluggable `StorageAdapter` interface with in-memory, Redis, DynamoDB, and Firestore backends, plus framework adapters for Express, Koa, and a generic handler for Lambda or gRPC, all with built-in distributed locking that prevents concurrent handler execution for the same key.

Packages

6 packages

@reaatech/idempotency-middleware

v1.0.0
A framework-agnostic TypeScript middleware that makes POST, PUT, and PATCH requests idempotent by caching responses keyed to an `Idempotency-Key` header, with pluggable storage adapters (in-memory, Redis, DynamoDB, Firestore) and distributed locking to prevent concurrent handler execution for the same key. Exports an `IdempotencyMiddleware` class with an `execute` method that wraps any async handler.
status
published
published
23 days ago

@reaatech/idempotency-middleware-adapter-dynamodb

v1.0.0
A DynamoDB storage adapter for `@reaatech/idempotency-middleware` that implements the `StorageAdapter` interface using conditional writes for distributed locking and TTL-compatible `expiresAt` attributes. It pairs with `@aws-sdk/client-dynamodb` and `@aws-sdk/util-dynamodb` at runtime.
status
published
published
23 days ago

@reaatech/idempotency-middleware-adapter-firestore

v1.0.0
A Firestore storage adapter for `@reaatech/idempotency-middleware` that provides transaction-gated distributed locking and TTL-compatible expiry via `expiresAt` Date fields. Exports a `FirestoreAdapter` class implementing the `StorageAdapter` interface, requiring a `@google-cloud/firestore` `Firestore` instance and an optional collection name.
status
published
published
23 days ago

@reaatech/idempotency-middleware-adapter-redis

v1.0.0
Redis storage adapter for `@reaatech/idempotency-middleware` that implements the `StorageAdapter` interface using ioredis, providing distributed idempotency caching with token-guarded locking via `SET NX` and Lua-based lock release.
status
published
published
23 days ago

@reaatech/idempotency-middleware-express

v1.0.0
Express middleware that caches responses keyed by the `Idempotency-Key` header, preventing duplicate processing of retried requests. It monkey-patches `res.json()` and `res.send()` to capture response bodies, and requires a storage adapter from `@reaatech/idempotency-middleware` (e.g., `MemoryAdapter`).
status
published
published
23 days ago

@reaatech/idempotency-middleware-koa

v1.0.0
Koa middleware that caches responses keyed by the `Idempotency-Key` header, preventing duplicate processing of the same request. It provides an `idempotentKoa(storage, config?)` function that wraps route handlers, automatically capturing `ctx.body` and `ctx.status` after `await next()` for replay on subsequent identical requests. Requires `koa` and a body parser middleware like `koa-bodyparser`.
status
published
published
23 days ago

Comments

Sign in with GitHub to comment and vote.

Loading comments…