UNPKG

nest-ratelimiter

Version:

Distributed consistent flexible NestJS rate limiter based on Redis

45 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TooManyRequestsException = void 0; const common_1 = require("@nestjs/common"); /** * Defines an HTTP exception for *Too Many Requests* type errors. * * @see [Base Exceptions](https://docs.nestjs.com/exception-filters#base-exceptions) * * @publicApi */ class TooManyRequestsException extends common_1.HttpException { /** * Instantiate an `TooManyRequestsException` Exception. * * @example * `throw new TooManyRequestsException()` * * @usageNotes * The constructor arguments define the HTTP response. * - The `message` argument defines the JSON response body. * - The `error` argument defines the HTTP Status Code. * * By default, the JSON response body contains two properties: * - `statusCode`: defaults to the Http Status Code provided in the `error` argument * - `message`: the string `'Too Many Requests'` by default; override this by supplying * a string in the `message` parameter. * * To override the entire JSON response body, pass an object. Nest will serialize * the object and return it as the JSON response body. * * The `error` argument is required, and should be a valid HTTP status code. * Best practice is to use the `HttpStatus` enum imported from `nestjs/common`. * * @param message string or object describing the error condition. * @param error HTTP response status code */ constructor( // eslint-disable-next-line @typescript-eslint/no-explicit-any message, error = 'Too Many Requests') { super(common_1.HttpException.createBody(message, error, common_1.HttpStatus.TOO_MANY_REQUESTS), common_1.HttpStatus.TOO_MANY_REQUESTS); } } exports.TooManyRequestsException = TooManyRequestsException; //# sourceMappingURL=too-many-requests.exception.js.map