akf-forum/lib.js

12 lines
390 B
JavaScript
Raw Normal View History

2022-09-21 23:06:14 +03:00
const RL = require('express-rate-limit');
2022-09-21 23:54:48 +03:00
module.exports = {
threadEnum: ["OPEN", "APPROVAL", "DELETED"],
RL(windowMs = 60_000, max = 1) {
return RL({
windowMs, max, standardHeaders: true, legacyHeaders: false,
handler: (req, res, next, opts) => !req.user?.admin ? res.error(opts.statusCode, "You are begin ratelimited") : next()
})
}
}