rate limit
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
ale 2024-11-06 01:47:03 +01:00
parent db1f3de490
commit 6c56252145

View File

@ -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
}))