From 30bfae978565084df5f0bbe62ccb5136a3f7a1b3 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Wed, 7 Sep 2022 10:39:38 +0200 Subject: [PATCH] feat: add config for rate_limit --- config.ts | 2 ++ src/server.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/config.ts b/config.ts index 56de43c..c1a29c1 100644 --- a/config.ts +++ b/config.ts @@ -29,6 +29,7 @@ interface Config { S3_REGION?: string; STORAGE: "filesystem" | "s3"; TRUST_PROXY: number; + RATE_LIMIT: number; } const config: Config = { CLIENT_ID: "CLIENT_ID", @@ -42,6 +43,7 @@ const config: Config = { ANONYMIZATION_MASK: "XXXX", PORT: 5000, TRUST_PROXY: 1, + RATE_LIMIT: 350, HOSTNAME: "anonymous.4open.science", DB_USERNAME: "admin", DB_PASSWORD: "password", diff --git a/src/server.ts b/src/server.ts index 6313420..e2a3014 100644 --- a/src/server.ts +++ b/src/server.ts @@ -62,7 +62,7 @@ export default async function start() { sendCommand: (...args: string[]) => redisClient.sendCommand(args), }), windowMs: 15 * 60 * 1000, // 15 minutes - max: 1000, // limit each IP + max: config.RATE_LIMIT, // limit each IP standardHeaders: true, legacyHeaders: false, // delayMs: 0, // disable delaying - full speed until the max limit is reached