fixes to config

This commit is contained in:
Bojan Kucera 2025-06-03 14:20:48 -04:00
parent 19f05a2a69
commit ef12c9d308
2 changed files with 29 additions and 34 deletions

View file

@ -23,10 +23,6 @@ import {
POSTGRES_DATABASE,
POSTGRES_USERNAME,
POSTGRES_PASSWORD,
// Backwards compatibility
databaseConfig,
DB_HOST,
DB_PORT,
} from './postgres';
import {
@ -148,24 +144,24 @@ async function databaseConnectionExample() {
const connectionString = `postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}`;
console.log('Database connection settings:');
console.log(`- Host: ${databaseConfig.POSTGRES_HOST}`);
console.log(`- Port: ${databaseConfig.POSTGRES_PORT}`);
console.log(`- Database: ${databaseConfig.POSTGRES_NAME}`);
console.log(`- SSL enabled: ${databaseConfig.POSTGRES_SSL}`);
console.log(`- Pool max connections: ${databaseConfig.POSTGRES_POOL_MAX}`);
console.log(`- Query timeout: ${databaseConfig.POSTGRES_QUERY_TIMEOUT}ms`);
console.log(`- Host: ${postgresConfig.POSTGRES_HOST}`);
console.log(`- Port: ${postgresConfig.POSTGRES_PORT}`);
console.log(`- Database: ${postgresConfig.POSTGRES_DATABASE}`);
console.log(`- SSL enabled: ${postgresConfig.POSTGRES_SSL}`);
console.log(`- Pool max connections: ${postgresConfig.POSTGRES_POOL_MAX}`);
console.log(`- Query timeout: ${postgresConfig.POSTGRES_QUERY_TIMEOUT}ms`);
// Example pool configuration
const poolConfig = {
host: databaseConfig.POSTGRES_HOST,
port: databaseConfig.POSTGRES_PORT,
database: databaseConfig.POSTGRES_NAME,
user: databaseConfig.POSTGRES_USER,
password: databaseConfig.POSTGRES_PASSWORD,
ssl: databaseConfig.POSTGRES_SSL,
min: databaseConfig.POSTGRES_POOL_MIN,
max: databaseConfig.POSTGRES_POOL_MAX,
idleTimeoutMillis: databaseConfig.POSTGRES_POOL_IDLE_TIMEOUT,
host: postgresConfig.POSTGRES_HOST,
port: postgresConfig.POSTGRES_PORT,
database: postgresConfig.POSTGRES_DATABASE,
user: postgresConfig.POSTGRES_USERNAME,
password: postgresConfig.POSTGRES_PASSWORD,
ssl: postgresConfig.POSTGRES_SSL,
min: postgresConfig.POSTGRES_POOL_MIN,
max: postgresConfig.POSTGRES_POOL_MAX,
idleTimeoutMillis: postgresConfig.POSTGRES_POOL_IDLE_TIMEOUT,
};
console.log('Pool configuration:', poolConfig);
@ -378,7 +374,7 @@ function configurationValidationExample() {
}
// Validate database connection settings
if (databaseConfig.POSTGRES_POOL_MAX < databaseConfig.POSTGRES_POOL_MIN) {
if (postgresConfig.POSTGRES_POOL_MAX < postgresConfig.POSTGRES_POOL_MIN) {
throw new ConfigurationError('Database max pool size must be greater than min pool size');
}
@ -629,16 +625,16 @@ function multiDatabaseServiceExample() {
// PostgreSQL for operational data
postgresql: {
host: databaseConfig.POSTGRES_HOST,
port: databaseConfig.POSTGRES_PORT,
database: databaseConfig.POSTGRES_NAME,
username: databaseConfig.POSTGRES_USER,
password: databaseConfig.POSTGRES_PASSWORD,
ssl: databaseConfig.POSTGRES_SSL,
host: postgresConfig.POSTGRES_HOST,
port: postgresConfig.POSTGRES_PORT,
database: postgresConfig.POSTGRES_DATABASE,
username: postgresConfig.POSTGRES_USERNAME,
password: postgresConfig.POSTGRES_PASSWORD,
ssl: postgresConfig.POSTGRES_SSL,
pool: {
min: databaseConfig.POSTGRES_POOL_MIN,
max: databaseConfig.POSTGRES_POOL_MAX,
idleTimeout: databaseConfig.POSTGRES_POOL_IDLE_TIMEOUT,
min: postgresConfig.POSTGRES_POOL_MIN,
max: postgresConfig.POSTGRES_POOL_MAX,
idleTimeout: postgresConfig.POSTGRES_POOL_IDLE_TIMEOUT,
},
},
@ -715,10 +711,10 @@ function serviceConfigurationExample() {
environment: getEnvironment(),
},
database: {
host: databaseConfig.POSTGRES_HOST,
port: databaseConfig.POSTGRES_PORT,
name: databaseConfig.POSTGRES_NAME,
ssl: databaseConfig.POSTGRES_SSL,
host: postgresConfig.POSTGRES_HOST,
port: postgresConfig.POSTGRES_PORT,
name: postgresConfig.POSTGRES_DATABASE,
ssl: postgresConfig.POSTGRES_SSL,
}, logging: {
level: loggingConfig.LOG_LEVEL,
console: loggingConfig.LOG_CONSOLE,

File diff suppressed because one or more lines are too long