express-rate-limiter-ts
Version:
A powerful, flexible and modern rate limiter middleware for Express.js written in TypeScript.
38 lines (37 loc) • 1.07 kB
TypeScript
import { IRateLimitStore, RateLimitInfo, RateLimitStats } from '../types/rateLimiter';
export declare class RedisStore implements IRateLimitStore {
private client;
private windowMs;
private statsKey;
private banPrefix;
private countPrefix;
constructor(options: {
url: string;
windowMs: number;
});
incr(key: string): Promise<RateLimitInfo>;
get(key: string): Promise<{
count: number;
resetTime: number;
}>;
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;
} | {
banned: boolean;
banExpiresAt?: undefined;
reason?: undefined;
}>;
getBanned(): Promise<{
[key: string]: {
banExpiresAt: Date;
reason: string;
};
}>;
unban(key: string): Promise<void>;
}