fixed some issues in config service

This commit is contained in:
Bojan Kucera 2025-06-03 12:14:38 -04:00
parent 2f5309d80f
commit 23f7614b29
10 changed files with 125 additions and 43 deletions

View file

@ -14,11 +14,24 @@ const defaultDatabaseConfig: DatabaseConfig = {
port: 6379,
maxRetriesPerRequest: 3
},
timescaleDB: {
questDB: {
host: 'localhost',
port: 8812,
database: 'stockbot',
user: 'admin',
httpPort: 9000
},
mongodb: {
uri: 'mongodb://localhost:27017',
database: 'stockbot'
},
postgres: {
host: 'localhost',
port: 5432,
database: 'stockbot',
user: 'postgres'
user: 'postgres',
poolSize: 10,
ssl: false
}
};
@ -26,7 +39,7 @@ const defaultDatabaseConfig: DatabaseConfig = {
* Load database configuration from environment variables
*/
export function loadDatabaseConfig(): DatabaseConfig {
const config: DatabaseConfig = {
const config = {
dragonfly: {
host: getEnvVar('DRAGONFLY_HOST') || defaultDatabaseConfig.dragonfly.host,
port: getNumericEnvVar('DRAGONFLY_PORT', defaultDatabaseConfig.dragonfly.port),
@ -34,12 +47,29 @@ export function loadDatabaseConfig(): DatabaseConfig {
maxRetriesPerRequest: getNumericEnvVar('DRAGONFLY_MAX_RETRIES_PER_REQUEST',
defaultDatabaseConfig.dragonfly.maxRetriesPerRequest)
},
timescaleDB: {
host: getEnvVar('TIMESCALE_HOST') || defaultDatabaseConfig.timescaleDB.host,
port: getNumericEnvVar('TIMESCALE_PORT', defaultDatabaseConfig.timescaleDB.port),
database: getEnvVar('TIMESCALE_DB') || defaultDatabaseConfig.timescaleDB.database,
user: getEnvVar('TIMESCALE_USER') || defaultDatabaseConfig.timescaleDB.user,
password: getEnvVar('TIMESCALE_PASSWORD')
questDB: {
host: getEnvVar('QUESTDB_HOST') || defaultDatabaseConfig.questDB.host,
port: getNumericEnvVar('QUESTDB_PORT', defaultDatabaseConfig.questDB.port),
database: getEnvVar('QUESTDB_DB') || defaultDatabaseConfig.questDB.database,
user: getEnvVar('QUESTDB_USER') || defaultDatabaseConfig.questDB.user,
password: getEnvVar('QUESTDB_PASSWORD'),
httpPort: getNumericEnvVar('QUESTDB_HTTP_PORT', defaultDatabaseConfig.questDB.httpPort)
},
mongodb: {
uri: getEnvVar('MONGODB_URI') || defaultDatabaseConfig.mongodb.uri,
database: getEnvVar('MONGODB_DATABASE') || defaultDatabaseConfig.mongodb.database,
username: getEnvVar('MONGODB_USERNAME'),
password: getEnvVar('MONGODB_PASSWORD'),
options: process.env.MONGODB_OPTIONS ? JSON.parse(process.env.MONGODB_OPTIONS) : undefined
},
postgres: {
host: getEnvVar('POSTGRES_HOST') || defaultDatabaseConfig.postgres.host,
port: getNumericEnvVar('POSTGRES_PORT', defaultDatabaseConfig.postgres.port),
database: getEnvVar('POSTGRES_DB') || defaultDatabaseConfig.postgres.database,
user: getEnvVar('POSTGRES_USER') || defaultDatabaseConfig.postgres.user,
password: getEnvVar('POSTGRES_PASSWORD'),
ssl: process.env.POSTGRES_SSL === 'true',
poolSize: getNumericEnvVar('POSTGRES_POOL_SIZE', defaultDatabaseConfig.postgres.poolSize)
}
};