Skip to content

Latest commit

 

History

History
113 lines (65 loc) · 3.34 KB

File metadata and controls

113 lines (65 loc) · 3.34 KB

@node-idempotency/core / Exports / Idempotency

Class: Idempotency

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Idempotency(storage, options?): Idempotency

Parameters

Name Type
storage StorageAdapter
options? IdempotencyOptions

Returns

Idempotency

Defined in

packages/core/src/idempotency.ts:20

Properties

options

options: Required<Omit<IdempotencyOptions, "skipRequest">> & { skipRequest?: (req: IdempotencyParamsWithDefaults) => boolean | Promise<boolean> }

Defined in

packages/core/src/idempotency.ts:19

Methods

onRequest

onRequest<BodyType, ErrorType>(req): Promise<undefined | IdempotencyResponse<BodyType, ErrorType>>

Type parameters

Name
BodyType
ErrorType

Parameters

Name Type
req IdempotencyParams

Returns

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

Defined in

packages/core/src/idempotency.ts:112


onResponse

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.

Type parameters

Name
BodyType
ErrorType

Parameters

Name Type
req IdempotencyParams
res IdempotencyResponse<BodyType, ErrorType>

Returns

Promise<void>

Defined in

packages/core/src/idempotency.ts:157