UNPKG

@eristack/idempotency

Version:

Idempotency-Key guard with Drizzle store, scoped keys, lease, Express/Nest/client adapters

19 lines (18 loc) • 682 B
import "../chunk-CGZBV6BD.js"; // src/client/index.ts function createIdempotencyClientFetch(options = {}) { const header = options.header ?? "Idempotency-Key"; const fetchImpl = options.fetch ?? fetch; const createKey = options.createKey ?? (() => crypto.randomUUID()); return async function idempotentFetch(input, init) { const key = init?.idempotencyKey ?? createKey(); const headers = new Headers(init?.headers); if (!headers.has(header)) headers.set(header, key); const { idempotencyKey: _drop, ...rest } = init ?? {}; return fetchImpl(input, { ...rest, headers }); }; } export { createIdempotencyClientFetch }; //# sourceMappingURL=index.js.map