From 79e1adc5ce5414eaed8b755603b2317fde22680e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Thu, 1 Jul 2021 11:16:13 +0200 Subject: :sparkles: finished Rate Limit --- src/Server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Server.ts') diff --git a/src/Server.ts b/src/Server.ts index 54c8db0d..326fcc5c 100644 --- a/src/Server.ts +++ b/src/Server.ts @@ -56,7 +56,7 @@ export class FosscordServer extends Server { db.collection("emojis").createIndex({ id: 1 }, { unique: true }), db.collection("invites").createIndex({ code: 1 }, { unique: true }), db.collection("invites").createIndex({ expires_at: 1 }, { expireAfterSeconds: 0 }), // after 0 seconds of expires_at the invite will get delete - db.collection("ratelimits").createIndex({ created_at: 1 }, { expireAfterSeconds: 1000 }) + db.collection("ratelimits").createIndex({ expires_at: 1 }, { expireAfterSeconds: 0 }) ]); } @@ -69,7 +69,6 @@ export class FosscordServer extends Server { this.app.use(CORS); this.app.use(Authentication); - this.app.use(RateLimit({ count: 10, error: 10, window: 5 })); this.app.use(BodyParser({ inflate: true, limit: 1024 * 1024 * 2 })); const languages = await fs.readdir(path.join(__dirname, "..", "locales")); const namespaces = await fs.readdir(path.join(__dirname, "..", "locales", "en")); @@ -94,6 +93,7 @@ export class FosscordServer extends Server { const prefix = Router(); // @ts-ignore this.app = prefix; + prefix.use(RateLimit({ bucket: "global", count: 10, error: 10, window: 5, bot: 250 })); prefix.use("/guilds/:id", RateLimit({ count: 10, window: 5 })); prefix.use("/webhooks/:id", RateLimit({ count: 10, window: 5 })); prefix.use("/channels/:id", RateLimit({ count: 10, window: 5 })); -- cgit 1.5.1