dino-express
Version:
DinO enabled REST framework based on express
37 lines (36 loc) • 1.12 kB
TypeScript
import { type Request } from 'express';
import { type Response } from '../Response';
import { AbstractPolicy } from './AbstractPolicy';
interface Configuration {
resetInterval: number;
window: number;
allow: number;
}
export declare class QuotaPolicy extends AbstractPolicy {
private readonly buckets;
private configuration;
private cleanUpJob;
constructor();
preDestroy(): void;
/**
* Apply the quota policy. The quota is calculated based on **window** and **allow** configuration
* parameters and based on the IP address of the remote client.
*
* @param {Any} req the client request
* @returns true if the number of requests on the defined window is less than the allow configuration
* parameter for the specific client, false otherwise
*
* @protected
* @implements AbstractPolicy#apply(req)
*/
apply(req: Request): boolean;
configure(configuration: Configuration): void;
protected onDeny(res: Response): void;
/**
* Remove expired buckets
*
* @private
*/
private removeExpired;
}
export {};