@exceptionless/fetchclient
Version:
A simple fetch client with middleware support for Deno and the browser.
50 lines • 1.62 kB
TypeScript
import type { FetchClientMiddleware } from "./FetchClientMiddleware.js";
import { RateLimiter, type RateLimiterOptions } from "./RateLimiter.js";
/**
* Rate limiting error thrown when requests exceed the rate limit.
*/
export declare class RateLimitError extends Error {
readonly resetTime: number;
readonly remainingRequests: number;
constructor(resetTime: number, remainingRequests: number, message?: string);
}
/**
* Configuration options for the rate limiting middleware.
*/
export interface RateLimitMiddlewareOptions extends RateLimiterOptions {
/**
* Whether to throw an error when rate limit is exceeded.
* If false, the middleware will set a 429 status response.
* @default true
*/
throwOnRateLimit?: boolean;
/**
* Custom error message when rate limit is exceeded.
*/
errorMessage?: string;
/**
* Whether to automatically update rate limits based on response headers.
* @default true
*/
autoUpdateFromHeaders?: boolean;
}
/**
* Rate limiting middleware instance that can be shared across requests.
*/
export declare class RateLimitMiddleware {
#private;
private readonly throwOnRateLimit;
private readonly errorMessage?;
private readonly autoUpdateFromHeaders;
constructor(options: RateLimitMiddlewareOptions);
/**
* Gets the underlying rate limiter instance.
*/
get rateLimiter(): RateLimiter;
/**
* Creates the middleware function.
* @returns The middleware function
*/
middleware(): FetchClientMiddleware;
}
//# sourceMappingURL=RateLimitMiddleware.d.ts.map