From 8fefa8d3608f325c44ea7db4d508423279a24b3d Mon Sep 17 00:00:00 2001 From: cskiwi Date: Sat, 7 Oct 2023 12:39:18 +0200 Subject: [PATCH] feat: cache the config for better performance see: https://github.com/nodejs/node/issues/3104 --- apps/api/src/app/app.module.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/api/src/app/app.module.ts b/apps/api/src/app/app.module.ts index a4ea006df..adb002229 100644 --- a/apps/api/src/app/app.module.ts +++ b/apps/api/src/app/app.module.ts @@ -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, @@ -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')}`, ); } }