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

File diff suppressed because one or more lines are too long