From 6c5625214552fc5ebee12fe9dcd4cff486cf6d01 Mon Sep 17 00:00:00 2001 From: ale Date: Wed, 6 Nov 2024 01:47:03 +0100 Subject: [PATCH] rate limit --- server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 6eeaa49..0275d13 100644 --- a/server.js +++ b/server.js @@ -10,7 +10,7 @@ const apexinstance = require('./lib/apex'), constant = require('./lib/constant'), http = require('http'), express = require('express'), - rateLimit = require("express-rate-limit"), + rateLimit = require('express-rate-limit'), app = express(), events = require('events'), { generateKeyPairSync } = require('crypto'), @@ -131,11 +131,11 @@ app.set('json spaces', 2) app.set('trust proxy', true) logger(app) app.use(rateLimit({ - windowMs: 5 * 60 * 1000, // 5 minutes - limit: 10, // each IP can make up to 10 requests per `windowsMs` (5 minutes) + windowMs: 1 * 60 * 1000, // 1 minutes + limit: 120, // each IP can make up to 120 requests per `windowsMs` (5 minutes) standardHeaders: true, // add the `RateLimit-*` headers to the response legacyHeaders: false, - delayAfter: 10, // allow 10 requests per `windowMs` (5 minutes) without slowing them down + delayAfter: 30, // allow 30 requests per `windowMs` (5 minutes) without slowing them down delayMs: (hits) => hits * 200, // add 200 ms of delay to every request after the 10th maxDelayMs: 5000 }))