@routup/rate-limit
Version:
Routup rate limiter.
61 lines • 1.62 kB
TypeScript
import type { IncrementResponse, Options } from '../type';
import type { Store } from './type';
export declare class MemoryStore implements Store {
/**
* The duration of time before which all hit counts are reset (in milliseconds).
*/
windowMs: number;
/**
* The map that stores the number of hits for each client in memory.
*/
hits: {
[key: string]: number | undefined;
};
/**
* The time at which all hit counts will be reset.
*/
resetTime: Date;
/**
* Reference to the active timer.
*/
interval?: NodeJS.Timer;
/**
* Method that initializes the store.
*
* @param options {Options} - The options used to setup the middleware.
*/
init(options: Options): void;
/**
* Method to increment a client's hit counter.
*
* @param key {string} - The identifier for a client.
*
* @returns {IncrementResponse} - The number of hits and reset time for that client.
*
* @public
*/
increment(key: string): Promise<IncrementResponse>;
/**
* Method to decrement a client's hit counter.
*
* @param key {string} - The identifier for a client.
*
* @public
*/
decrement(key: string): Promise<void>;
/**
* Method to reset a client's hit counter.
*
* @param key {string} - The identifier for a client.
*
* @public
*/
reset(key: string): Promise<void>;
/**
* Method to reset everyone's hit counter.
*
* @public
*/
resetAll(): Promise<void>;
}
//# sourceMappingURL=memory.d.ts.map