express-rate-limiter-ts
Version:
A powerful, flexible and modern rate limiter middleware for Express.js written in TypeScript.
30 lines (29 loc) • 904 B
TypeScript
import { RateLimitInfo, RateLimitStats, IRateLimitStore } from '../types/rateLimiter';
export declare class MemoryStore implements IRateLimitStore {
private hits;
private windowMs;
private stats;
private banned;
constructor(windowMs: number);
incr(key: string): Promise<RateLimitInfo>;
get(key: string): Promise<{
count: number;
resetTime: number;
} | undefined>;
reset(key: string): Promise<void>;
recordStat(route: string): Promise<void>;
getStats(): Promise<RateLimitStats>;
ban(key: string, seconds: number, reason: string): Promise<void>;
isBanned(key: string): Promise<{
banned: boolean;
banExpiresAt?: Date;
reason?: string;
}>;
getBanned(): Promise<{
[key: string]: {
banExpiresAt: Date;
reason: string;
};
}>;
unban(key: string): Promise<void>;
}