diff --git a/apps/backend/src/app/db/db.service.ts b/apps/backend/src/app/db/db.service.ts index 8093944..b960ecf 100644 --- a/apps/backend/src/app/db/db.service.ts +++ b/apps/backend/src/app/db/db.service.ts @@ -12,7 +12,12 @@ export class DbService { constructor(private configService: ConfigService) {} async onModuleInit() { - const dbConfig = { + const dbConfig = this.getDbConfig(); + this.initializeClients(dbConfig); + } + + private getDbConfig() { + return { host: this.configService.get("POSTGRES_HOST"), port: Number(this.configService.get("POSTGRES_PORT")), database: this.configService.get("POSTGRES_DATABASE"), @@ -20,18 +25,18 @@ export class DbService { password: this.configService.get("POSTGRES_PASSWORD"), ssl: Boolean(this.configService.get("POSTGRES_SSL")), }; + } + private initializeClients(dbConfig: any) { this.migrationClient = postgres({ ...dbConfig, max: 1, }); - this.standardClient = postgres({ ...dbConfig, }); } - //onModuleDestroy async onModuleDestroy() { await this.migrationClient.end(); await this.standardClient.end();