diff --git a/packages/server/src/application/Bootstrap.ts b/packages/server/src/application/Bootstrap.ts index 89b84e2..96c91b3 100644 --- a/packages/server/src/application/Bootstrap.ts +++ b/packages/server/src/application/Bootstrap.ts @@ -17,7 +17,7 @@ export class Bootstrap implements IBootstrap { readonly database: IDatabase constructor( - readonly config: IConfig, + private readonly config: IConfig, protected readonly namespace: Namespace = createNamespace('application'), protected readonly exit: (code: number) => void = process.exit, ) { @@ -25,14 +25,18 @@ export class Bootstrap implements IBootstrap { this.application = this.createApplication(this.database) } + getConfig(): IConfig { + return this.config + } + protected createDatabase(): IDatabase { const sqlLogger = new SqlLogger( loggerFactory.getLogger('sql'), this.namespace) - return new Database(this.namespace, sqlLogger, this.config.app.db) + return new Database(this.namespace, sqlLogger, this.getConfig().app.db) } protected createApplication(database: IDatabase): IApplication { - return new Application(this.config, database) + return new Application(this.getConfig(), database) } async listen( diff --git a/packages/server/src/application/IBootstrap.ts b/packages/server/src/application/IBootstrap.ts index c540bde..53a0079 100644 --- a/packages/server/src/application/IBootstrap.ts +++ b/packages/server/src/application/IBootstrap.ts @@ -6,7 +6,7 @@ import {IConfig} from './IConfig' export interface IBootstrap { readonly application: IApplication readonly database: IDatabase - readonly config: IConfig + getConfig(): IConfig listen(port?: number | string, hostname?: string): Promise getAddress(): AddressInfo | string close(): Promise diff --git a/packages/server/src/test-utils/TestUtils.ts b/packages/server/src/test-utils/TestUtils.ts index 59bdb40..b283784 100644 --- a/packages/server/src/test-utils/TestUtils.ts +++ b/packages/server/src/test-utils/TestUtils.ts @@ -19,7 +19,7 @@ export class TestUtils { constructor(readonly bootstrap: IBootstrap) { this.app = bootstrap.application.server - this.context = this.bootstrap.config.app.context + this.context = this.bootstrap.getConfig().app.context this.transactionManager = this.bootstrap.database.transactionManager } @@ -142,7 +142,7 @@ export class TestUtils { request = (baseUrl = '') => { return new RequestTester( this.app, - `${this.bootstrap.config.app.baseUrl.path!}${baseUrl}`) + `${this.bootstrap.getConfig().app.baseUrl.path!}${baseUrl}`) } private getCookies(setCookiesString: string[]): string {