File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { CacheMonitoringService } from './cache-monitoring.service';
1212
1313@Injectable ( )
1414export class CacheMetricsInterceptor implements NestInterceptor {
15+ // CacheMonitoringService is expected to be a singleton provided by the CacheModule
1516 constructor ( private cacheMonitoringService : CacheMonitoringService ) { }
1617
1718 intercept ( context : ExecutionContext , next : CallHandler ) : Observable < any > {
Original file line number Diff line number Diff line change @@ -51,8 +51,9 @@ async function bootstrap() {
5151 app . useGlobalInterceptors ( new RateLimitHeadersInterceptor ( ) ) ;
5252
5353 // Apply cache metrics interceptor
54- const cacheMonitoringService = app . get ( CacheMonitoringService ) ;
55- app . useGlobalInterceptors ( new CacheMetricsInterceptor ( cacheMonitoringService ) ) ;
54+ // Retrieve the singleton instance from the DI container to ensure consistent dependency injection
55+ const cacheMetricsInterceptor = app . get ( CacheMetricsInterceptor ) ;
56+ app . useGlobalInterceptors ( cacheMetricsInterceptor ) ;
5657
5758 app . useGlobalPipes (
5859 new ValidationPipe ( {
You can’t perform that action at this time.
0 commit comments