Skip to content

Commit

Permalink
feat: cache the config for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
cskiwi committed Oct 7, 2023
1 parent 33e61dc commit 8fefa8d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ import { QueueModule } from '@badman/backend-queue';
import { SearchModule } from '@badman/backend-search';
import { TranslateModule } from '@badman/backend-translate';
import { TwizzitModule } from '@badman/backend-twizzit';
import versionPackage from '../version.json';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import versionPackage from '../version.json';

const productionModules = [];
if (process.env.NODE_ENV === 'production') {
console.log('Loaded static module');

productionModules.push(
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'badman'),
exclude: ['api/*', '/graphql'],
})
}),
);
}

@Module({
imports: [
...productionModules,
ConfigModule.forRoot(),
ConfigModule.forRoot({
cache: true,
}),
AuthorizationModule,
GrapqhlModule,
DatabaseModule,
Expand All @@ -59,7 +59,7 @@ export class AppModule {
private readonly logger = new Logger(AppModule.name);
constructor(configService: ConfigService) {
this.logger.log(
`${AppModule.name} loaded, env: ${configService.get('NODE_ENV')}`
`${AppModule.name} loaded, env: ${configService.get('NODE_ENV')}`,
);
}
}

0 comments on commit 8fefa8d

Please sign in to comment.