mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-24 14:35:27 +00:00
✨ add option to disable all rate limits
This commit is contained in:
@@ -6,6 +6,8 @@ export function BodyParser(opts?: OptionsJson) {
|
||||
const jsonParser = bodyParser.json(opts);
|
||||
|
||||
return (req: Request, res: Response, next: NextFunction) => {
|
||||
if (!req.headers["content-type"]) req.headers["content-type"] = "application/json";
|
||||
|
||||
jsonParser(req, res, (err) => {
|
||||
if (err) {
|
||||
// TODO: different errors for body parser (request size limit, wrong body type, invalid body, ...)
|
||||
|
||||
@@ -107,7 +107,8 @@ export default function rateLimit(opts: {
|
||||
}
|
||||
|
||||
export async function initRateLimits(app: Router) {
|
||||
const { routes, global, ip, error } = Config.get().limits.rate;
|
||||
const { routes, global, ip, error, disabled } = Config.get().limits.rate;
|
||||
if (disabled) return;
|
||||
await listenEvent(EventRateLimit, (event) => {
|
||||
Cache.set(event.channel_id as string, event.data);
|
||||
event.acknowledge?.();
|
||||
|
||||
Reference in New Issue
Block a user