Refactor database SSL configuration for improved clarity and flexibility

- Updated SSL settings in database.module.ts and ormconfig.ts to use DATABASE_SSL environment variable for better control over SSL usage.
- Clarified comments to indicate that SSL is only necessary for remote PostgreSQL instances, enhancing understanding for local development setups.
This commit is contained in:
Dorian
2026-02-13 17:28:28 +00:00
parent b8ab347c68
commit 8c43448306
2 changed files with 10 additions and 13 deletions

View File

@@ -37,12 +37,11 @@ import { Unique } from './validators/unique.validator';
query_timeout: 30_000, query_timeout: 30_000,
statement_timeout: 30_000, statement_timeout: 30_000,
}, },
// No SSL for local/Docker environments // SSL is only needed for remote/managed PostgreSQL (e.g. AWS RDS).
ssl: // Self-hosted Docker setups use an internal network — no SSL required.
configService.get('ENVIRONMENT') === 'local' || ssl: configService.get('DATABASE_SSL') === 'true'
configService.get('ENVIRONMENT') === 'development' ? { rejectUnauthorized: false }
? false : false,
: { rejectUnauthorized: false },
}), }),
}), }),
], ],

View File

@@ -18,11 +18,9 @@ export default new DataSource({
migrations: ['dist/database/migrations/*.{ts,js}'], migrations: ['dist/database/migrations/*.{ts,js}'],
migrationsTableName: 'typeorm_migrations', migrationsTableName: 'typeorm_migrations',
synchronize: false, synchronize: false,
ssl: // SSL is only needed for remote/managed PostgreSQL (e.g. AWS RDS).
configService.get('ENVIRONMENT') === 'local' || // Self-hosted Docker setups use an internal network — no SSL required.
configService.get('ENVIRONMENT') === 'development' ssl: configService.get('DATABASE_SSL') === 'true'
? false ? { rejectUnauthorized: false }
: { : false,
rejectUnauthorized: false,
},
}); });