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:
@@ -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 },
|
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -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,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user