Make server work with browserify --node

This commit is contained in:
Jerko Steiner 2019-04-15 14:28:56 +12:00
parent dcc2fb4dc8
commit 5f662a1ac1
3 changed files with 10 additions and 6 deletions

View File

@ -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(

View File

@ -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<void>
getAddress(): AddressInfo | string
close(): Promise<void>

View File

@ -19,7 +19,7 @@ export class TestUtils<T extends IRoutes> {
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<T extends IRoutes> {
request = (baseUrl = '') => {
return new RequestTester<T>(
this.app,
`${this.bootstrap.config.app.baseUrl.path!}${baseUrl}`)
`${this.bootstrap.getConfig().app.baseUrl.path!}${baseUrl}`)
}
private getCookies(setCookiesString: string[]): string {