monkeytype/backend/middlewares/rate-limit.js

34 lines
693 B
JavaScript
Raw Normal View History

2021-08-28 04:40:38 +08:00
const rateLimit = require("express-rate-limit");
exports.limit60perhour = rateLimit({
windowMs: 60 * 60 * 1000, // 60 min
max: 60,
message: {
message: "Too many requests, please try again later",
},
});
exports.limit3perday = rateLimit({
windowMs: 24 * 60 * 60 * 1000, // 1 day
max: 3,
message: {
message: "Too many requests, please try again later",
},
});
exports.limit1persec = rateLimit({
windowMs: 60 * 1000,
max: 60,
message: {
message: "Too many requests, please try again later",
},
});
exports.limit500perhour = rateLimit({
windowMs: 60 * 60 * 1000,
max: 500,
message: {
message: "Too many requests, please try again later",
},
});