Browse Source

refactor edge case

yuken 3 năm trước cách đây
mục cha
commit
9c67ea83e9
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      packages/app/src/server/middlewares/api-rate-limiter.ts

+ 3 - 1
packages/app/src/server/middlewares/api-rate-limiter.ts

@@ -58,7 +58,9 @@ const _consumePoints = async(
   }
 
   // for edge case
-  maxRequests += 1;
+  if (maxRequests % 2 === 0) {
+    maxRequests += 1;
+  }
 
   const consumePoints = POINTS_THRESHOLD / maxRequests;
   await rateLimiter.consume(key, consumePoints);