mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 08:26:59 +03:00
Setup different ratelimit for views and votes
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
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,
|
||||
module.exports = (limitConfig) => rateLimit({
|
||||
windowMs: limitConfig.windowMs,
|
||||
max: limitConfig.max,
|
||||
message: limitConfig.message,
|
||||
statusCode: limitConfig.statusCode,
|
||||
headers: false,
|
||||
keyGenerator: (req /*, res*/) => {
|
||||
return getHash(req.ip, 1);
|
||||
return getHash(getIP(req), 1);
|
||||
},
|
||||
skip: (/*req, res*/) => {
|
||||
// skip rate limit if running in test mode
|
||||
Reference in New Issue
Block a user