apiLimiter.js 344 B

12345678910111213141516
  1. const rateLimit = require('express-rate-limit');
  2. const apiLimiter = rateLimit({
  3. windowMs: 15 * 60 * 1000,
  4. max: 2000,
  5. handler: (req, res, next) => {
  6. return res.status(400).json({
  7. status: 'error',
  8. code: 400,
  9. data: 'Bad request',
  10. message: 'Too many requests, please try again later.',
  11. });
  12. },
  13. });
  14. module.exports = apiLimiter;