File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed
plugins/verdaccio-rate-limit-middleware/src Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ import type {
66} from '@verdaccio/types' ;
77
88interface RateLimitConfig {
9- redisUrl : string ;
9+ // Optional in config; VERDACCIO_REDIS_URL env var takes precedence when set.
10+ redisUrl ?: string ;
1011 windowSeconds : number ;
1112 maxRequests : number ;
1213}
@@ -42,7 +43,14 @@ class RateLimitMiddleware implements MiddlewarePlugin<any> {
4243 public constructor ( private readonly config : RateLimitConfig , options : PluginOptions < any > ) {
4344 this . logger = options . logger . child ( { plugin : 'rate-limit-middleware' } ) ;
4445
45- this . redisUrl = config . redisUrl ;
46+ const envRedisUrl = process . env . VERDACCIO_REDIS_URL ;
47+ this . redisUrl =
48+ ( envRedisUrl && envRedisUrl . trim ( ) . length > 0
49+ ? envRedisUrl
50+ : config . redisUrl && config . redisUrl . trim ( ) . length > 0
51+ ? config . redisUrl
52+ : 'redis://redis:6379' ) ;
53+
4654 this . windowSeconds =
4755 typeof config . windowSeconds === 'number' && config . windowSeconds > 0
4856 ? config . windowSeconds
Original file line number Diff line number Diff line change @@ -35,7 +35,9 @@ middlewares:
3535 timeoutMs : 60000
3636 policyId : " lenient"
3737 " @secure-registry/verdaccio-rate-limit-middleware " :
38- redisUrl : ${VERDACCIO_REDIS_URL:-redis://redis:6379}
38+ # Redis URL for rate limiting. VERDACCIO_REDIS_URL env var (if set)
39+ # takes precedence in the middleware implementation.
40+ redisUrl : " redis://redis:6379"
3941 windowSeconds : 86400 # 24h window
4042 maxRequests : 400 # 400 requests per 24h
4143
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ middlewares:
3737 timeoutMs : 60000
3838 policyId : " strict"
3939 " @secure-registry/verdaccio-rate-limit-middleware " :
40- redisUrl : ${VERDACCIO_REDIS_URL:-redis://redis:6379}
40+ # Redis URL for rate limiting. VERDACCIO_REDIS_URL env var (if set)
41+ # takes precedence in the middleware implementation.
42+ redisUrl : " redis://redis:6379"
4143 windowSeconds : 86400 # 24h window
4244 maxRequests : 400 # 400 requests per 24h
4345
You can’t perform that action at this time.
0 commit comments