node-traffic-shield
Version:
Versatile rate-limiting middleware for Node.js, compatible with both Express.js and NestJS, designed to safeguard applications from excessive traffic.
24 lines (19 loc) • 715 B
TypeScript
declare module 'node-traffic-shield' {
interface RateLimiterOptions {
limit: number;
windowMs: number;
}
// Define a generic Request, Response, and NextFunction type
// These types should be compatible with the types used in Express.js and NestJS
interface GenericRequest {
[key: string]: any;
}
interface GenericResponse {
status: (statusCode: number) => GenericResponse;
json: (body: any) => GenericResponse;
[key: string]: any;
}
type NextFunction = () => void;
function rateLimiter(options: RateLimiterOptions): (req: GenericRequest, res: GenericResponse, next: NextFunction) => void;
export default rateLimiter;
}