From a4afbd48c848576ea1ae4cd8fee7cb5344b2d9f8 Mon Sep 17 00:00:00 2001 From: Elhussien Mohamed Mahmoud Awad Date: Sat, 2 May 2026 19:09:03 +0300 Subject: [PATCH 1/5] Add SSL configuration to database settings --- src/config/database.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/config/database.config.ts b/src/config/database.config.ts index e45c8e71..c7b67b2c 100644 --- a/src/config/database.config.ts +++ b/src/config/database.config.ts @@ -14,4 +14,8 @@ export const getDatabaseConfig = (configService: ConfigService): TypeOrmModuleOp logging: configService.get('NODE_ENV') === 'development', migrations: [`${__dirname}/../migrations/*{.ts,.js}`], migrationsRun: false, // Run migrations manually + + ssl:{ + rejectUnauthorized: false, + }, }); From c6fc63c08a35a0a3e1f56276f949c10c4c5ca59f Mon Sep 17 00:00:00 2001 From: Elhussien Mohamed Mahmoud Awad Date: Sat, 2 May 2026 19:18:30 +0300 Subject: [PATCH 2/5] Update ormconfig.ts --- src/ormconfig.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ormconfig.ts b/src/ormconfig.ts index f5bd3f56..531fa46f 100644 --- a/src/ormconfig.ts +++ b/src/ormconfig.ts @@ -21,6 +21,9 @@ const options: DataSourceOptions & SeederOptions = { logging: !isProd, seeds: [`${base}/database/seeds/**/*.${ext}`], factories: [`${base}/database/factories/**/*.${ext}`], + ssl: { + rejectUnauthorized: false, + }, }; -export default new DataSource(options); \ No newline at end of file +export default new DataSource(options); From 8b1e1b1b11e2eb43e4f769978124636a3d657b36 Mon Sep 17 00:00:00 2001 From: Elhussien Mohamed Mahmoud Awad Date: Sat, 2 May 2026 19:24:17 +0300 Subject: [PATCH 3/5] Refactor database config to use DATABASE_URL Replaced individual database configuration parameters with a single DATABASE_URL parameter. --- src/config/database.config.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/config/database.config.ts b/src/config/database.config.ts index c7b67b2c..72260274 100644 --- a/src/config/database.config.ts +++ b/src/config/database.config.ts @@ -4,11 +4,7 @@ import { ConfigService } from '@nestjs/config'; export const getDatabaseConfig = (configService: ConfigService): TypeOrmModuleOptions => ({ type: 'postgres', - host: configService.get('DB_HOST'), - port: configService.get('DB_PORT'), - username: configService.get('DB_USERNAME'), - password: configService.get('DB_PASSWORD'), - database: configService.get('DB_DATABASE'), + url: configService.get('DATABASE_URL'), entities: [`${__dirname}/../**/*.entity{.ts,.js}`], synchronize: false, // NEVER true in production logging: configService.get('NODE_ENV') === 'development', From 1a22addcf3da37f43deb878f40b1d0498493410d Mon Sep 17 00:00:00 2001 From: Elhussien Mohamed Mahmoud Awad Date: Sat, 2 May 2026 19:32:26 +0300 Subject: [PATCH 4/5] Update database configuration for SSL settings --- src/config/database.config.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/config/database.config.ts b/src/config/database.config.ts index 72260274..7a104dba 100644 --- a/src/config/database.config.ts +++ b/src/config/database.config.ts @@ -4,14 +4,19 @@ import { ConfigService } from '@nestjs/config'; export const getDatabaseConfig = (configService: ConfigService): TypeOrmModuleOptions => ({ type: 'postgres', + url: configService.get('DATABASE_URL'), + entities: [`${__dirname}/../**/*.entity{.ts,.js}`], - synchronize: false, // NEVER true in production + synchronize: false, logging: configService.get('NODE_ENV') === 'development', migrations: [`${__dirname}/../migrations/*{.ts,.js}`], - migrationsRun: false, // Run migrations manually + migrationsRun: false, - ssl:{ - rejectUnauthorized: false, + ssl: true, // 👈 important + extra: { + ssl: { + rejectUnauthorized: false, + }, }, }); From fd65a497349d665774bc39cf42bf65b949d48fcd Mon Sep 17 00:00:00 2001 From: Elhussien Mohamed Mahmoud Awad Date: Sat, 2 May 2026 19:38:13 +0300 Subject: [PATCH 5/5] Refactor database connection options in ormconfig Updated database connection configuration to use DATABASE_URL and modified SSL settings. --- src/ormconfig.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ormconfig.ts b/src/ormconfig.ts index 531fa46f..30e1d7d9 100644 --- a/src/ormconfig.ts +++ b/src/ormconfig.ts @@ -10,19 +10,22 @@ const base = isProd ? 'dist' : 'src'; const options: DataSourceOptions & SeederOptions = { type: 'postgres', - host: process.env.DB_HOST || 'localhost', - port: parseInt(process.env.DB_PORT ?? '5432', 10), - username: process.env.DB_USERNAME || 'postgres', - password: process.env.DB_PASSWORD, - database: process.env.DB_DATABASE, + + url: process.env.DATABASE_URL, + entities: [`${base}/**/*.entity.${ext}`], migrations: [`${base}/database/migrations/*.${ext}`], synchronize: false, logging: !isProd, + seeds: [`${base}/database/seeds/**/*.${ext}`], factories: [`${base}/database/factories/**/*.${ext}`], - ssl: { - rejectUnauthorized: false, + + ssl: true, + extra: { + ssl: { + rejectUnauthorized: false, + }, }, };