소스 검색

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 {
     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 = {