UNPKG

restifyx.js

Version:

Advanced API endpoint handler system with automatic documentation

38 lines (37 loc) 1.12 kB
import type { Request, Response, NextFunction } from "express"; interface RateLimitOptions { windowMs: number; max: number; message?: string; keyGenerator?: (req: Request) => string; skip?: (req: Request) => boolean; headers?: boolean; standardHeaders?: boolean; legacyHeaders?: boolean; store?: any; draft_polli_ratelimit_headers?: boolean; } interface RateLimitInfo { count: number; resetTime: number; lastAttempt: number; } declare class MemoryRateLimiter { private limits; private interval; private logger; constructor(cleanupIntervalMs?: number); check(key: string, options: RateLimitOptions): { limited: boolean; info: RateLimitInfo; }; private cleanup; stop(): void; getKeys(): string[]; reset(key: string): boolean; resetAll(): void; getInfo(key: string): RateLimitInfo | undefined; } declare const memoryRateLimiter: MemoryRateLimiter; export declare function rateLimitMiddleware(options: RateLimitOptions): (req: Request, res: Response, next: NextFunction) => void; export { memoryRateLimiter };