فهرست منبع

Refactoring of RateLimiterFactory

Shun Miyazawa 1 سال پیش
والد
کامیت
4a28490384
1فایلهای تغییر یافته به همراه3 افزوده شده و 5 حذف شده
  1. 3 5
      apps/app/src/features/rate-limiter/middleware/rate-limiter-factory.ts

+ 3 - 5
apps/app/src/features/rate-limiter/middleware/rate-limiter-factory.ts

@@ -14,11 +14,9 @@ class RateLimiterFactory {
   getOrCreateRateLimiter(endpoint: string, maxRequests: number): RateLimiterMongo {
   getOrCreateRateLimiter(endpoint: string, maxRequests: number): RateLimiterMongo {
     const key = this.generateKey(endpoint);
     const key = this.generateKey(endpoint);
 
 
-    if (this.rateLimiters.has(key)) {
-      const instance = this.rateLimiters.get(key);
-      if (instance != null) {
-        return instance;
-      }
+    const cachedRateLimiter = this.rateLimiters.get(key);
+    if (cachedRateLimiter != null) {
+      return cachedRateLimiter;
     }
     }
 
 
     const opts: IRateLimiterMongoOptions = {
     const opts: IRateLimiterMongoOptions = {