@lacspace/idempotency
Make any operation exactly-once with an idempotency key — replay stored results on retries, safe under concurrency, with optional request fingerprinting. Framework-agnostic, pluggable store, zero-dependency, isomorphic.
npm i @lacspace/idempotencyUsage
import { idempotent } from "@lacspace/idempotency";
// in a POST handler — the client sends an Idempotency-Key header
const key = request.headers.get("idempotency-key")!;
const { value, replayed } = await idempotent(key, () => chargeCard(order));
// first request: runs chargeCard, stores the result → replayed: false
// any retry with the same key: returns the SAME result → replayed: true (no second charge)
return Response.json(value);Exports 7
IdempotencyIdempotencyConflictErrorIdempotencyKeyReuseErrorMemoryIdempotencyStoreReplayedErrorfingerprintidempotentKeywords
More in Backend Kit
Generate real PDFs — invoices, receipts & documents — with zero dependencies and no headless browser. Accurate text layout, auto page-breaks, batteries-included invoice() & receipt() generators. Isomorphic (Node, edge, browser).
@lacspace/signed-urlHMAC-signed, expiring URLs & tokens over Web Crypto — secure download links, magic-login links, unsubscribe links and one-time-action tokens. Tamper-proof, timing-safe, zero-config. Isomorphic (Node, edge, browser).
@lacspace/webhooksThe webhook toolkit for both directions — sign & deliver outgoing webhooks with retries, and verify incoming ones (timing-safe, replay-protected) with Stripe / GitHub / Shopify presets. Plus event ids & idempotency. One internal dependency (@lacspace/crypto), isomorphic.