mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-20 12:19:03 +00:00
fix: align with express-rate-limit v6
This commit is contained in:
parent
28ba5834ea
commit
be345e3d34
@ -161,7 +161,7 @@ module.exports = {
|
||||
/*
|
||||
Rate limits.
|
||||
Please be aware that these apply to all users, including site owners.
|
||||
https://github.com/nfriedly/express-rate-limit#configuration-options
|
||||
https://github.com/nfriedly/express-rate-limit#usage
|
||||
*/
|
||||
rateLimits: [
|
||||
{
|
||||
@ -172,6 +172,8 @@ module.exports = {
|
||||
config: {
|
||||
windowMs: 1000,
|
||||
max: 10,
|
||||
legacyHeaders: true,
|
||||
standardHeaders: true,
|
||||
message: {
|
||||
success: false,
|
||||
description: 'Rate limit reached, please try again in a while.'
|
||||
@ -187,6 +189,8 @@ module.exports = {
|
||||
config: {
|
||||
windowMs: 5 * 1000,
|
||||
max: 2,
|
||||
legacyHeaders: true,
|
||||
standardHeaders: true,
|
||||
message: {
|
||||
success: false,
|
||||
description: 'Rate limit reached, please try again in 5 seconds.'
|
||||
@ -200,7 +204,9 @@ module.exports = {
|
||||
],
|
||||
config: {
|
||||
windowMs: 30 * 1000,
|
||||
max: 6
|
||||
max: 6,
|
||||
legacyHeaders: true,
|
||||
standardHeaders: true
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -211,6 +217,8 @@ module.exports = {
|
||||
config: {
|
||||
windowMs: 60 * 1000,
|
||||
max: 1,
|
||||
legacyHeaders: true,
|
||||
standardHeaders: true,
|
||||
message: {
|
||||
success: false,
|
||||
description: 'Rate limit reached, please try again in 60 seconds.'
|
||||
|
@ -17,7 +17,7 @@ const express = require('express')
|
||||
const helmet = require('helmet')
|
||||
const nunjucks = require('nunjucks')
|
||||
const path = require('path')
|
||||
const RateLimit = require('express-rate-limit')
|
||||
const rateLimit = require('express-rate-limit')
|
||||
const readline = require('readline')
|
||||
const serveStatic = require('@bobbywibowo/serve-static')
|
||||
const { accessSync, constants } = require('fs')
|
||||
@ -83,9 +83,9 @@ safe.enable('view cache')
|
||||
|
||||
// Configure rate limits
|
||||
if (Array.isArray(config.rateLimits) && config.rateLimits.length) {
|
||||
for (const rateLimit of config.rateLimits) {
|
||||
const limiter = new RateLimit(rateLimit.config)
|
||||
for (const route of rateLimit.routes) {
|
||||
for (const _rateLimit of config.rateLimits) {
|
||||
const limiter = rateLimit(_rateLimit.config)
|
||||
for (const route of _rateLimit.routes) {
|
||||
safe.use(route, limiter)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user