From 69d74be3d1dfec125ef633d3e402f0a21067cd91 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 20 May 2023 13:43:21 +0530 Subject: [PATCH] fix: load config from appInitService Signed-off-by: Pranav C --- .../src/modules/global/global.module.ts | 7 ++++-- .../nocodb/src/services/app-init.service.ts | 22 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/modules/global/global.module.ts b/packages/nocodb/src/modules/global/global.module.ts index ee2124f563..b7aa2d6005 100644 --- a/packages/nocodb/src/modules/global/global.module.ts +++ b/packages/nocodb/src/modules/global/global.module.ts @@ -15,8 +15,11 @@ import type { Provider } from '@nestjs/common'; export const JwtStrategyProvider: Provider = { provide: JwtStrategy, - useFactory: async (usersService: UsersService) => { - const config = Noco.config; + useFactory: async ( + usersService: UsersService, + appInitService: AppInitService, + ) => { + const config = appInitService.appConfig; await Noco.initJwt(); diff --git a/packages/nocodb/src/services/app-init.service.ts b/packages/nocodb/src/services/app-init.service.ts index aeeb5591ac..b305425347 100644 --- a/packages/nocodb/src/services/app-init.service.ts +++ b/packages/nocodb/src/services/app-init.service.ts @@ -9,11 +9,27 @@ import NcUpgrader from '../version-upgrader/NcUpgrader'; import type { IEventEmitter } from '../modules/event-emitter/event-emitter.interface'; import type { Provider } from '@nestjs/common'; -@Injectable() -export class AppInitService {} +export class AppInitService { + private readonly config: any; + + constructor(config) { + this.config = config; + } + + get appConfig(): any { + return this.config; + } +} export const appInitServiceProvider: Provider = { provide: AppInitService, + // initialize app, + // 1. init cache + // 2. init db connection and create if not exist + // 3. init meta and set to Noco + // 4. init jwt + // 5. init plugin manager + // 6. run upgrader useFactory: async ( connection: Connection, metaService: MetaService, @@ -46,7 +62,7 @@ export const appInitServiceProvider: Provider = { await NcUpgrader.upgrade({ ncMeta: Noco._ncMeta }); // todo: move app config to app-init service - return new AppInitService(); + return new AppInitService(connection.config); }, inject: [Connection, MetaService, 'IEventEmitter'], };