Rate Limiter


This middleware stores ip address of a request in memory and will throw an 429 Too Many Requests error when there will be too many requests than the number set in the configuration. Based on https://github.com/jhurliman/node-rate-limiter and https://github.com/ptarjan/node-cache

It will help you solve this security problem.

export type RateLimiter = {  tokensPerInterval: number;  interval: string | number;  fireImmediately?: boolean;};

To write a custom logic for this middleware follow this pattern:

// nuxt.config.js{  modules: [    "nuxt-security",  ],  security: {    rateLimiter: {      value: {        tokensPerInterval: 200,        interval: "day",        fireImmediately: false      },      route: '/my-custom-route',      throwError: false, // optional    }  }}