mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 22:47:12 +03:00
19 lines
569 B
JavaScript
19 lines
569 B
JavaScript
const config = require('../config.js');
|
|
const getIP = require('../utils/getIP.js');
|
|
const getHash = require('../utils/getHash.js');
|
|
const rateLimit = require('express-rate-limit');
|
|
|
|
module.exports = rateLimit({
|
|
windowMs: config.rateLimit.vote.windowMs,
|
|
max: config.rateLimit.vote.max,
|
|
message: config.rateLimit.vote.message,
|
|
headers: false,
|
|
keyGenerator: (req /*, res*/) => {
|
|
return getHash(req.ip, 1);
|
|
},
|
|
skip: (/*req, res*/) => {
|
|
// skip rate limit if running in test mode
|
|
return process.env.npm_lifecycle_script === 'node test.js';
|
|
}
|
|
});
|