while idempotency-key is typically found in header, in some cases, it is better to allow application developer to decide where to get the key from.
acceptance criteria
- add an optional parameter
idempotencyKeyExtractor to options
- its a method and
- takes RequestWithDefaults as args similar to skipRequest
- return string | undefined
and then use options or use default implementation from here:
|
private getIdempotencyKey( |
|
req: IdempotencyParamsWithDefaults, |
|
): string | undefined { |
|
const key = Object.keys(req.headers).find( |
|
(key) => key.toLowerCase() === req.options.idempotencyKey.toLowerCase(), |
|
); |
|
return key ? (req.headers[key] as string) : undefined; |
|
} |
while idempotency-key is typically found in header, in some cases, it is better to allow application developer to decide where to get the key from.
acceptance criteria
idempotencyKeyExtractortooptions- takes
RequestWithDefaultsas args similar toskipRequest- return string | undefined
and then use options or use default implementation from here:
node-idempotency/packages/core/src/idempotency.ts
Lines 53 to 60 in bf04255