From 202cc248119fc369a43fb6e1a91c8023dc69041e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Thu, 12 Aug 2021 18:57:25 +0200 Subject: :sparkles: rate limit now configurable in the config --- src/Server.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/Server.ts') diff --git a/src/Server.ts b/src/Server.ts index 3e20695a..7299425a 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -12,7 +12,7 @@ import { BodyParser } from "./middlewares/BodyParser"; import express, { Router, Request, Response } from "express"; import mongoose from "mongoose"; import path from "path"; -import RateLimit from "./middlewares/RateLimit"; +import { initRateLimits } from "./middlewares/RateLimit"; import TestClient from "./middlewares/TestClient"; // this will return the new updated document for findOneAndUpdate @@ -86,12 +86,8 @@ export class FosscordServer extends Server { const api = Router(); // @ts-ignore this.app = api; - api.use(RateLimit({ bucket: "global", count: 10, window: 5, bot: 250 })); - api.use(RateLimit({ bucket: "error", count: 5, error: true, window: 5, bot: 15, onlyIp: true })); - api.use("/guilds/:id", RateLimit({ count: 5, window: 5 })); - api.use("/webhooks/:id", RateLimit({ count: 5, window: 5 })); - api.use("/channels/:id", RateLimit({ count: 5, window: 5 })); + initRateLimits(api); this.routes = await this.registerRoutes(path.join(__dirname, "routes", "/")); app.use("/api/v8", api); app.use("/api/v9", api); -- cgit 1.5.1