idempotency

cart · /core·function

Built-in middleware that deduplicates mutations sharing the same ctx.idempotencyKey within windowMs. Replays return the cached cart without invoking the inner chain. Mutations without a key pass through unaltered.

Signature

@nordcom/commerce-cart
function idempotency(opts: { store: IdempotencyStore; windowMs: number }): CartMiddleware;

Parameters

NameTypeDescription
opts{ store: IdempotencyStore; windowMs: number }

Returns

A that short-circuits duplicates.

Example

const kernel = createCart({
  adapter,
  middleware: [idempotency({ store: memoryIdempotencyStore(), windowMs: 30_000 })],
});

RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter

On this page