Skip to content

Commit

Permalink
make caching enabled depend on set env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Lms24 committed Oct 17, 2024
1 parent 1f118dd commit 65e9d4b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions api-node/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module } from '@nestjs/common';
import { Module, Provider } from '@nestjs/common';
import { PackagesController } from './packages/packages.controller';
import { HealthCheckController } from './health/healthCheck.controller';
import { MarketingController } from './marketing/marketing.controller';
Expand All @@ -9,6 +9,19 @@ import { RegistryService } from './common/registry.service';
import { SentryGlobalFilter, SentryModule } from '@sentry/nestjs/setup';
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core';
import { CacheInterceptor, CacheModule } from '@nestjs/cache-manager';

const providers: Provider[] = [
RegistryService,
{ provide: APP_FILTER, useClass: SentryGlobalFilter },
];

if (process.env.REGISTRY_ENABLE_CACHE === '1') {
providers.push({
provide: APP_INTERCEPTOR,
useClass: CacheInterceptor,
});
}

@Module({
imports: [
SentryModule.forRoot(),
Expand All @@ -24,13 +37,6 @@ import { CacheInterceptor, CacheModule } from '@nestjs/cache-manager';
SdksController,
AwsLambdaLayersController,
],
providers: [
RegistryService,
{ provide: APP_FILTER, useClass: SentryGlobalFilter },
{
provide: APP_INTERCEPTOR,
useClass: CacheInterceptor,
},
],
providers,
})
export class AppModule {}

0 comments on commit 65e9d4b

Please sign in to comment.