UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

35 lines (34 loc) 1.08 kB
/** * @module Lock */ import { type ILockFactoryBase } from "../../../lock/contracts/_module.js"; import { type MiddlewareFn } from "../../../middleware/contracts/_module.js"; import { type ITimeSpan } from "../../../time-span/contracts/time-span.contract.js"; import { type Invokable } from "../../../utilities/_module.js"; /** * @group Middleware */ export type LockMiddlewareSettings<TParameters extends Array<unknown> = Array<unknown>> = { /** * @default * ```ts * (...args) => JSON.stringify(args) * ``` */ key?: Invokable<TParameters, string>; /** * @default * ```ts * import { v4 } from "uuid"; * * () => v4() * ``` */ lockId?: Invokable<TParameters, string>; ttl?: ITimeSpan | null; }; /** * IMPORT_PATH: `"@daiso-tech/core/lock/middlewares"` * @group Middleware */ export declare function lockMiddlewareFactory(lockFactory: ILockFactoryBase): <TParameters extends Array<unknown>, TReturn>(settings: LockMiddlewareSettings<TParameters>) => MiddlewareFn<TParameters, Promise<TReturn>>;