Express middleware for idempotent POST requests using Idempotency-Key header (version 1.0.2, stable release, active development). Provides pluggable stores (Memory, Redis, Postgres), in-flight concurrency control with wait or reject strategies, and safe response replay with header whitelist. TypeScript-first, ESM-only, requires Node ≥18 and Express 4 or 5. Differentiators: built-in in-flight handling via wait timeout polling, stable response fingerprinting, and separate replay header whitelist for security-aware caching of location headers without cookies or auth tokens. Designed for payment, order, and webhook idempotency scenarios.
npm install express-idempotency-middlewareVerified import paths — ran on the pinned version, not inferred.
Creates an Express app with idempotency middleware on POST /payments, using MemoryStore, wait strategy for in-flight requests, and replay header whitelist.
Use ESM imports: import { idempotencyMiddleware } from 'express-idempotency-middleware'Implement custom store implementing Store interface or use provided examples for RedisStore/PostgresStore
Always send a valid non-empty Idempotency-Key header, or set requireKey:true to enforce
Upgrade Node.js to version 18 or later
Change to ESM import: import { idempotencyMiddleware } from 'express-idempotency-middleware' or use dynamic import()Ensure custom store implements Store interface with get(key), set(key, value, ttl?), and delete(key) async methods
Ensure all retries use exactly the same request body, headers (except whitelist), and method