@node-idempotency/core / Exports / Idempotency
• new Idempotency(storage, options?): Idempotency
| Name | Type |
|---|---|
storage |
StorageAdapter |
options? |
IdempotencyOptions |
packages/core/src/idempotency.ts:20
• options: Required<Omit<IdempotencyOptions, "skipRequest">> & { skipRequest?: (req: IdempotencyParamsWithDefaults) => boolean | Promise<boolean> }
packages/core/src/idempotency.ts:19
▸ onRequest<BodyType, ErrorType>(req): Promise<undefined | IdempotencyResponse<BodyType, ErrorType>>
| Name |
|---|
BodyType |
ErrorType |
| Name | Type |
|---|---|
req |
IdempotencyParams |
Promise<undefined | IdempotencyResponse<BodyType, ErrorType>>
Throws
IdempotencyError if request is already in progress or invalid
to be called on receiving the request, if the key is already cached, returns or throws based on the status, if returns nothing
packages/core/src/idempotency.ts:112
▸ onResponse<BodyType, ErrorType>(req, res): Promise<void>
to be called on receiving response/error, it cached the response/error and updates status to complete. subsequent requests can use cached response.
| Name |
|---|
BodyType |
ErrorType |
| Name | Type |
|---|---|
req |
IdempotencyParams |
res |
IdempotencyResponse<BodyType, ErrorType> |
Promise<void>