1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-13 00:26:55 -05:00
shimapan/app/util/rateLimit.js

10 lines
353 B
JavaScript

const config = require('config');
const rateLimit = require('express-rate-limit');
const rateLimitRequest = (window, max, skipSuccessful) =>
config.get('RateLimit.enable')
? rateLimit({windowMs: window * 1000, max: max, skipSuccessfulRequests: skipSuccessful})
: (req, res, next) => { next(); };
module.exports = rateLimitRequest;