コンテンツにスキップ
日本語

IdempotencyOptionsType

このコンテンツはまだ日本語訳がありません。

IdempotencyOptionsType = object

Defined in: src/http/cache/IdempotencyOptions.ts:13

Plain options-object shape accepted by idempotent.

readonly cache: Cache

Defined in: src/http/cache/IdempotencyOptions.ts:14


readonly optional headerName?: string

Defined in: src/http/cache/IdempotencyOptions.ts:22

Header to read the idempotency key from. Default: 'idempotency-key' (the standard). Header names are matched case-insensitively against the request.headers map (which holds them lower-cased).


readonly optional identity?: (request) => string | Promise<string>

Defined in: src/http/cache/IdempotencyOptions.ts:44

Derive a per-caller scope folded into the cache key so a cached response is NEVER replayed to a different caller (security audit HTTP-4). Without it, two callers sending the same method + path + body under the same Idempotency-Key share one cache entry — fine for a public endpoint, unsafe when the response is identity-specific (the second caller would get the first caller’s data / Set-Cookie). Return the authenticated principal (user / tenant / API-key id), e.g. identity: (request) => request.headers['x-account-id'] ?? 'anon'.

HttpRequest

string | Promise<string>


readonly optional keyPrefix?: string

Defined in: src/http/cache/IdempotencyOptions.ts:26

Cache-key namespace. Default: 'idem:'.


readonly optional missingHeader?: "reject" | "pass-through"

Defined in: src/http/cache/IdempotencyOptions.ts:33

What to do when the request lacks the header. Default: 'reject' (respond 400). Setting 'pass-through' runs the handler unchanged — useful when only some clients use idempotency and you don’t want to break the others.


readonly optional ttlMs?: number

Defined in: src/http/cache/IdempotencyOptions.ts:16

How long to remember responses. Default: 24 hours.