feat: add limit

This commit is contained in:
lyz05
2024-01-08 12:11:55 +08:00
parent 5b9591af09
commit c69625b32a

View File

@@ -18,8 +18,8 @@ const rateLimit = require('express-rate-limit');
const MAX_count_today = 1000;
const allowlist = ['::1', '::ffff:127.0.0.1'];
const apiLimiter = rateLimit({
windowMs: 5 * 60 * 1000, // 5 minutes
max: 20, // limit each IP to 20 requests per windowMs
windowMs: 2 * 60 * 1000, // 2 minutes
max: 10, // limit each IP to 10 requests per windowMs
message: 'Too many requests from this IP, please try again later',
standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
skipFailedRequests: true, // Don't count failed requests (status >= 400)