diff --git a/api/example.env b/api/example.env index bea3064d4f..991edb1563 100644 --- a/api/example.env +++ b/api/example.env @@ -28,8 +28,8 @@ REDIS_PASSWORD=null #################################################################################################### # Rate Limiting -CONSUMED_POINTS_LIMIT=5 -CONSUMED_RESET_DURATION=5 +CONSUMED_POINTS_LIMIT=100 +CONSUMED_RESET_DURATION=1 EXEC_EVENLY=true BLOCK_POINT_DURATION=0 #################################################################################################### diff --git a/api/src/cli/utils/create-env/env-stub.liquid b/api/src/cli/utils/create-env/env-stub.liquid index 989dde0c5e..207fc8dc8d 100644 --- a/api/src/cli/utils/create-env/env-stub.liquid +++ b/api/src/cli/utils/create-env/env-stub.liquid @@ -14,6 +14,11 @@ {{ redisServer }} #################################################################################################### +# Rate Limiting + +{{ rateLimits}} +#################################################################################################### + # File Storage {{ storage }} diff --git a/api/src/cli/utils/create-env/index.ts b/api/src/cli/utils/create-env/index.ts index b27d2b6d2d..dac4aa439f 100644 --- a/api/src/cli/utils/create-env/index.ts +++ b/api/src/cli/utils/create-env/index.ts @@ -31,8 +31,8 @@ const defaults = { REDIS_PASSWORD: null, }, rateLimits: { - CONSUMED_POINTS_LIMIT: 5, - CONSUMED_RESET_DURATION: 5, + CONSUMED_POINTS_LIMIT: 100, + CONSUMED_RESET_DURATION: 1, EXEC_EVENLY: true, BLOCK_POINT_DURATION: 0, }, diff --git a/api/src/middleware/rate-limiter.ts b/api/src/middleware/rate-limiter.ts index ac90d299fe..cd64261447 100644 --- a/api/src/middleware/rate-limiter.ts +++ b/api/src/middleware/rate-limiter.ts @@ -41,7 +41,7 @@ const rateLimiter: RequestHandler = asyncHandler(async (req, res, next) => { try { await rateLimiterRedis.consume(req.ip); - } catch (rejRes) { + } catch (err) { // If there is no error, rateLimiterRedis promise rejected with number of ms before next request allowed const secs = Math.round(rejRes.msBeforeNext / 1000) || 1; res.set('Retry-After', String(secs));