UNPKG

@adonisjs/limiter

Version:

Rate limiting package for AdonisJS framework

47 lines (46 loc) 1.13 kB
/** * Represents the response from a limiter operation, containing information * about request limits, consumption, and availability. */ export declare class LimiterResponse { /** * Allowed number of requests for a pre-defined * duration */ limit: number; /** * Requests remaining for the pre-defined duration */ remaining: number; /** * Requests consumed for the pre-defined duration */ consumed: number; /** * Number of seconds after which the requests count will * reset */ availableIn: number; constructor(rawResponse: { limit: number; remaining: number; consumed: number; availableIn: number; }); /** * Returns a JSON representation of the limiter response. * * @example * ```ts * const response = limiter.get('user:1') * console.log(response.toJSON()) * // { limit: 10, remaining: 5, consumed: 5, availableIn: 30 } * ``` */ toJSON(): { limit: number; remaining: number; consumed: number; availableIn: number; }; }