final config changes
This commit is contained in:
parent
718ace05b0
commit
19f05a2a69
7 changed files with 311 additions and 51 deletions
|
|
@ -15,15 +15,19 @@ import {
|
|||
} from './core';
|
||||
|
||||
import {
|
||||
// Database configuration
|
||||
// PostgreSQL configuration
|
||||
postgresConfig,
|
||||
PostgresConfig,
|
||||
POSTGRES_HOST,
|
||||
POSTGRES_PORT,
|
||||
POSTGRES_DATABASE,
|
||||
POSTGRES_USERNAME,
|
||||
POSTGRES_PASSWORD,
|
||||
// Backwards compatibility
|
||||
databaseConfig,
|
||||
DatabaseConfig,
|
||||
DB_HOST,
|
||||
DB_PORT,
|
||||
DB_NAME,
|
||||
DB_USER,
|
||||
DB_PASSWORD,
|
||||
} from './database';
|
||||
} from './postgres';
|
||||
|
||||
import {
|
||||
// QuestDB configuration
|
||||
|
|
@ -119,18 +123,17 @@ function basicUsageExample() {
|
|||
// Get the current environment
|
||||
const env = getEnvironment();
|
||||
console.log(`Current environment: ${env}`);
|
||||
|
||||
// Access individual configuration values
|
||||
console.log(`Database host: ${DB_HOST}`);
|
||||
console.log(`Database port: ${DB_PORT}`);
|
||||
// Access individual configuration values
|
||||
console.log(`Database host: ${POSTGRES_HOST}`);
|
||||
console.log(`Database port: ${POSTGRES_PORT}`);
|
||||
console.log(`Log level: ${LOG_LEVEL}`);
|
||||
|
||||
// Access full configuration objects
|
||||
// Access full database config objects
|
||||
console.log(`Full database config:`, {
|
||||
host: databaseConfig.DB_HOST,
|
||||
port: databaseConfig.DB_PORT,
|
||||
name: databaseConfig.DB_NAME,
|
||||
ssl: databaseConfig.DB_SSL,
|
||||
host: postgresConfig.POSTGRES_HOST,
|
||||
port: postgresConfig.POSTGRES_PORT,
|
||||
name: postgresConfig.POSTGRES_DATABASE,
|
||||
ssl: postgresConfig.POSTGRES_SSL,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -142,27 +145,27 @@ async function databaseConnectionExample() {
|
|||
|
||||
try {
|
||||
// Use the database configuration to create a connection string
|
||||
const connectionString = `postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}`;
|
||||
const connectionString = `postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}`;
|
||||
|
||||
console.log('Database connection settings:');
|
||||
console.log(`- Host: ${databaseConfig.DB_HOST}`);
|
||||
console.log(`- Port: ${databaseConfig.DB_PORT}`);
|
||||
console.log(`- Database: ${databaseConfig.DB_NAME}`);
|
||||
console.log(`- SSL enabled: ${databaseConfig.DB_SSL}`);
|
||||
console.log(`- Pool max connections: ${databaseConfig.DB_POOL_MAX}`);
|
||||
console.log(`- Query timeout: ${databaseConfig.DB_QUERY_TIMEOUT}ms`);
|
||||
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`);
|
||||
|
||||
// Example pool configuration
|
||||
const poolConfig = {
|
||||
host: databaseConfig.DB_HOST,
|
||||
port: databaseConfig.DB_PORT,
|
||||
database: databaseConfig.DB_NAME,
|
||||
user: databaseConfig.DB_USER,
|
||||
password: databaseConfig.DB_PASSWORD,
|
||||
ssl: databaseConfig.DB_SSL,
|
||||
min: databaseConfig.DB_POOL_MIN,
|
||||
max: databaseConfig.DB_POOL_MAX,
|
||||
idleTimeoutMillis: databaseConfig.DB_POOL_IDLE_TIMEOUT,
|
||||
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,
|
||||
};
|
||||
|
||||
console.log('Pool configuration:', poolConfig);
|
||||
|
|
@ -375,7 +378,7 @@ function configurationValidationExample() {
|
|||
}
|
||||
|
||||
// Validate database connection settings
|
||||
if (databaseConfig.DB_POOL_MAX < databaseConfig.DB_POOL_MIN) {
|
||||
if (databaseConfig.POSTGRES_POOL_MAX < databaseConfig.POSTGRES_POOL_MIN) {
|
||||
throw new ConfigurationError('Database max pool size must be greater than min pool size');
|
||||
}
|
||||
|
||||
|
|
@ -626,16 +629,16 @@ function multiDatabaseServiceExample() {
|
|||
|
||||
// PostgreSQL for operational data
|
||||
postgresql: {
|
||||
host: databaseConfig.DB_HOST,
|
||||
port: databaseConfig.DB_PORT,
|
||||
database: databaseConfig.DB_NAME,
|
||||
username: databaseConfig.DB_USER,
|
||||
password: databaseConfig.DB_PASSWORD,
|
||||
ssl: databaseConfig.DB_SSL,
|
||||
host: databaseConfig.POSTGRES_HOST,
|
||||
port: databaseConfig.POSTGRES_PORT,
|
||||
database: databaseConfig.POSTGRES_NAME,
|
||||
username: databaseConfig.POSTGRES_USER,
|
||||
password: databaseConfig.POSTGRES_PASSWORD,
|
||||
ssl: databaseConfig.POSTGRES_SSL,
|
||||
pool: {
|
||||
min: databaseConfig.DB_POOL_MIN,
|
||||
max: databaseConfig.DB_POOL_MAX,
|
||||
idleTimeout: databaseConfig.DB_POOL_IDLE_TIMEOUT,
|
||||
min: databaseConfig.POSTGRES_POOL_MIN,
|
||||
max: databaseConfig.POSTGRES_POOL_MAX,
|
||||
idleTimeout: databaseConfig.POSTGRES_POOL_IDLE_TIMEOUT,
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -712,10 +715,10 @@ function serviceConfigurationExample() {
|
|||
environment: getEnvironment(),
|
||||
},
|
||||
database: {
|
||||
host: databaseConfig.DB_HOST,
|
||||
port: databaseConfig.DB_PORT,
|
||||
name: databaseConfig.DB_NAME,
|
||||
ssl: databaseConfig.DB_SSL,
|
||||
host: databaseConfig.POSTGRES_HOST,
|
||||
port: databaseConfig.POSTGRES_PORT,
|
||||
name: databaseConfig.POSTGRES_NAME,
|
||||
ssl: databaseConfig.POSTGRES_SSL,
|
||||
}, logging: {
|
||||
level: loggingConfig.LOG_LEVEL,
|
||||
console: loggingConfig.LOG_CONSOLE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue