@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
75 lines (74 loc) • 2.53 kB
TypeScript
/**
* Rate Limiting Middleware
* Provides configurable rate limiting for server adapters
*/
import type { FixedWindowRateLimitConfig, MiddlewareDefinition, RateLimitEntry, RateLimitMiddlewareConfig, RateLimitStore } from "../../types/index.js";
/**
* In-memory rate limit store
*/
export declare class InMemoryRateLimitStore implements RateLimitStore {
private store;
private cleanupInterval?;
constructor();
get(key: string): Promise<RateLimitEntry | undefined>;
set(key: string, entry: RateLimitEntry): Promise<void>;
increment(key: string, windowMs: number): Promise<RateLimitEntry>;
reset(key: string): Promise<void>;
private cleanup;
destroy(): void;
}
/**
* Create rate limiting middleware
*
* Response headers set on all requests:
* - `X-RateLimit-Limit`: Maximum requests allowed per window
* - `X-RateLimit-Remaining`: Requests remaining in current window
* - `X-RateLimit-Reset`: Unix timestamp when the window resets
*
* Additional headers on rate limit exceeded (HTTP 429):
* - `Retry-After`: Seconds to wait before retrying
*
* @example
* ```typescript
* const rateLimiter = createRateLimitMiddleware({
* maxRequests: 100,
* windowMs: 15 * 60 * 1000, // 15 minutes
* skipPaths: ["/api/health"],
* });
*
* server.registerMiddleware(rateLimiter);
* ```
*/
export declare function createRateLimitMiddleware(config: RateLimitMiddlewareConfig): MiddlewareDefinition;
/**
* Re-export RateLimitError from errors for convenience
*/
export { RateLimitError } from "../errors.js";
/**
* Create a sliding window rate limiter
* More accurate than fixed window but slightly more complex
*/
export declare function createSlidingWindowRateLimitMiddleware(config: RateLimitMiddlewareConfig & {
/** Number of sub-windows for smoothing (default: 10) */
subWindows?: number;
}): MiddlewareDefinition;
/**
* Alias for InMemoryRateLimitStore for compatibility
*/
export { InMemoryRateLimitStore as MemoryRateLimitStore };
/**
* Create fixed window rate limit middleware
*
* Accepts config and optional store as separate parameters for compatibility.
* Returns rate limit headers in the response object.
*
* @example
* ```typescript
* const store = new MemoryRateLimitStore();
* const middleware = createFixedWindowRateLimitMiddleware(
* { windowMs: 60000, maxRequests: 10 },
* store
* );
* ```
*/
export declare function createFixedWindowRateLimitMiddleware(config: FixedWindowRateLimitConfig, store?: RateLimitStore): MiddlewareDefinition;