@sdflc/backend-helpers 1.0.116 → 1.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/BaseCore.js +3 -1
- package/build/apiContext.js +1 -1
- package/build/esm/BaseCore.js +3 -1
- package/build/esm/apiContext.js +1 -1
- package/package.json +1 -1
package/build/BaseCore.js
CHANGED
|
@@ -382,6 +382,7 @@ class BaseCore {
|
|
|
382
382
|
const ip = context.ipAddress || '';
|
|
383
383
|
const spaceId = context.spaceId || '';
|
|
384
384
|
if (!ip) {
|
|
385
|
+
this.logger.debug(`Cannot reset rate-limit counter for action '${scope}:${actionName}' as IP address is not available in context`);
|
|
385
386
|
return;
|
|
386
387
|
}
|
|
387
388
|
// Key format must match what checkRateLimit wrote:
|
|
@@ -491,10 +492,12 @@ class BaseCore {
|
|
|
491
492
|
const rules = this.collectRateLimitRules(actionName, callOverride);
|
|
492
493
|
if (rules.length === 0) {
|
|
493
494
|
// Nothing to check — skip limiter lookup entirely
|
|
495
|
+
this.logger.debug('No rate-limit rules apply to this action; skipping rate-limit check.');
|
|
494
496
|
return null;
|
|
495
497
|
}
|
|
496
498
|
const limiter = this.getRateLimiter();
|
|
497
499
|
if (!limiter) {
|
|
500
|
+
this.logger.debug('Rate-limit rules are defined but no limiter is available; skipping rate-limit check.');
|
|
498
501
|
// No limiter available (no context.rateLimiter, no config.rateLimiter) — allow through
|
|
499
502
|
return null;
|
|
500
503
|
}
|
|
@@ -503,7 +506,6 @@ class BaseCore {
|
|
|
503
506
|
const spaceId = context.spaceId || '';
|
|
504
507
|
// Stable key segment: prefer rule.action override, then actionName, then doingWhat
|
|
505
508
|
const actionKey = actionName || doingWhat;
|
|
506
|
-
this.logger.debug(`Checking ${rules.length} rate-limit counter(s) for action '${actionKey}' from IP '${ip}' in space '${spaceId}' on ${doingWhat}`);
|
|
507
509
|
// Run all counters in parallel — every applicable level is incremented on
|
|
508
510
|
// every request regardless of what the others return. This ensures counters
|
|
509
511
|
// stay accurate even when the request is ultimately blocked by another level.
|
package/build/apiContext.js
CHANGED
|
@@ -74,7 +74,7 @@ const createContextDefault = async (args) => {
|
|
|
74
74
|
// Priority: explicit rateLimiter arg > auto-construct from redisClient > none.
|
|
75
75
|
// null is a valid explicit value meaning "disable rate limiting entirely".
|
|
76
76
|
let rateLimiter = inRateLimiter;
|
|
77
|
-
if (rateLimiter
|
|
77
|
+
if (rateLimiter == null && redisClient != null) {
|
|
78
78
|
rateLimiter = new IpRateLimiter_1.IpRateLimiter(redisClient, logger);
|
|
79
79
|
}
|
|
80
80
|
const sharedContext = {
|
package/build/esm/BaseCore.js
CHANGED
|
@@ -376,6 +376,7 @@ class BaseCore {
|
|
|
376
376
|
const ip = context.ipAddress || '';
|
|
377
377
|
const spaceId = context.spaceId || '';
|
|
378
378
|
if (!ip) {
|
|
379
|
+
this.logger.debug(`Cannot reset rate-limit counter for action '${scope}:${actionName}' as IP address is not available in context`);
|
|
379
380
|
return;
|
|
380
381
|
}
|
|
381
382
|
// Key format must match what checkRateLimit wrote:
|
|
@@ -485,10 +486,12 @@ class BaseCore {
|
|
|
485
486
|
const rules = this.collectRateLimitRules(actionName, callOverride);
|
|
486
487
|
if (rules.length === 0) {
|
|
487
488
|
// Nothing to check — skip limiter lookup entirely
|
|
489
|
+
this.logger.debug('No rate-limit rules apply to this action; skipping rate-limit check.');
|
|
488
490
|
return null;
|
|
489
491
|
}
|
|
490
492
|
const limiter = this.getRateLimiter();
|
|
491
493
|
if (!limiter) {
|
|
494
|
+
this.logger.debug('Rate-limit rules are defined but no limiter is available; skipping rate-limit check.');
|
|
492
495
|
// No limiter available (no context.rateLimiter, no config.rateLimiter) — allow through
|
|
493
496
|
return null;
|
|
494
497
|
}
|
|
@@ -497,7 +500,6 @@ class BaseCore {
|
|
|
497
500
|
const spaceId = context.spaceId || '';
|
|
498
501
|
// Stable key segment: prefer rule.action override, then actionName, then doingWhat
|
|
499
502
|
const actionKey = actionName || doingWhat;
|
|
500
|
-
this.logger.debug(`Checking ${rules.length} rate-limit counter(s) for action '${actionKey}' from IP '${ip}' in space '${spaceId}' on ${doingWhat}`);
|
|
501
503
|
// Run all counters in parallel — every applicable level is incremented on
|
|
502
504
|
// every request regardless of what the others return. This ensures counters
|
|
503
505
|
// stay accurate even when the request is ultimately blocked by another level.
|
package/build/esm/apiContext.js
CHANGED
|
@@ -67,7 +67,7 @@ export const createContextDefault = async (args) => {
|
|
|
67
67
|
// Priority: explicit rateLimiter arg > auto-construct from redisClient > none.
|
|
68
68
|
// null is a valid explicit value meaning "disable rate limiting entirely".
|
|
69
69
|
let rateLimiter = inRateLimiter;
|
|
70
|
-
if (rateLimiter
|
|
70
|
+
if (rateLimiter == null && redisClient != null) {
|
|
71
71
|
rateLimiter = new IpRateLimiter(redisClient, logger);
|
|
72
72
|
}
|
|
73
73
|
const sharedContext = {
|