@clickup/rest-client
Version:
A syntax sugar tool around Node fetch() API, tailored to work with TypeScript and response validators
28 lines • 966 B
TypeScript
import type { Middleware } from "../RestOptions";
import type RestRequest from "../RestRequest";
/**
* Pacer is a class which allows to pace requests on some resource identified by
* the instance of this class.
*/
export interface Pacer {
/** Human readable name of the pacer, used when composing multiple pacers. */
readonly key: string;
/**
* Signals that we're about to send a request. Returns the delay we need to
* wait for before actually sending.
*/
pace(): Promise<PacerOutcome>;
}
/**
* A result of some Pacer work.
*/
export interface PacerOutcome {
delayMs: number;
reason: string;
}
/**
* Rest Client middleware that adds some delay between requests using one of
* Pacer implementations.
*/
export default function paceRequests(pacer: Pacer | ((req: RestRequest) => Promise<Pacer | null>) | null, delayMetric?: (delay: number, reason: string) => void): Middleware;
//# sourceMappingURL=paceRequests.d.ts.map