@olakai/sdk
Version:
This document demonstrates how to use the Olakai SDK with all its features.
19 lines • 834 B
TypeScript
import { Middleware } from "./index";
/**
* Create a rate limiting middleware
* This middleware limits the number of calls to a function within a specified time window.
* @param options - The options for the middleware
* @returns A middleware function
* @default options - {
* maxCalls: 100, // Maximum number of calls within the time window
* windowMs: 60000, // Time window in milliseconds
* keyGenerator: (args) => args[0], // Function to generate a key for the rate limit
* }
* @throws {Error} if the rate limit is exceeded
*/
export declare function createRateLimitMiddleware<TArgs extends any[], TResult>(options: {
maxCalls: number;
windowMs: number;
keyGenerator?: (args: TArgs) => string;
}): Middleware<TArgs, TResult>;
//# sourceMappingURL=rateLimiter.d.ts.map