@oxyhq/core 3.4.2 → 3.4.4

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.
@@ -25,7 +25,7 @@ function resolveKey(req) {
25
25
  if (userId) {
26
26
  return `user:${userId}`;
27
27
  }
28
- const ip = req.ip || req.socket?.remoteAddress || 'unknown';
28
+ const ip = req.ip || req.socket.remoteAddress || 'unknown';
29
29
  return ipKeyGenerator(ip);
30
30
  }
31
31
  /**
@@ -40,18 +40,18 @@ export function createOxyRateLimit(oxy, options = {}) {
40
40
  const limiter = rateLimit({
41
41
  windowMs,
42
42
  ...(store ? { store } : {}),
43
- max: ((req) => {
43
+ max: (req) => {
44
44
  const authed = req;
45
45
  const userId = authed.userId ?? authed.user?.id ?? authed.user?._id;
46
46
  return userId ? authenticatedMax : anonymousMax;
47
- }),
48
- keyGenerator: ((req) => resolveKey(req)),
47
+ },
48
+ keyGenerator: (req) => resolveKey(req),
49
49
  message,
50
50
  standardHeaders: true,
51
51
  legacyHeaders: false,
52
- skip: skip,
52
+ skip,
53
53
  });
54
- return ((req, res, next) => {
54
+ return (req, res, next) => {
55
55
  // Skipped paths bypass BOTH session resolution and limiting — cheap and
56
56
  // safe for static/streaming/health traffic.
57
57
  if (skip(req)) {
@@ -67,5 +67,5 @@ export function createOxyRateLimit(oxy, options = {}) {
67
67
  }
68
68
  limiter(req, res, next);
69
69
  });
70
- });
70
+ };
71
71
  }