no idea- added loki and other stuff to market-data-gateway, also added config lib
This commit is contained in:
parent
b957fb99aa
commit
1b71fc87ab
72 changed files with 6178 additions and 153 deletions
52
libs/config/src/database.ts
Normal file
52
libs/config/src/database.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Database configuration for Stock Bot services
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
import { getEnvVar, getNumericEnvVar, validateConfig } from './core';
|
||||
import { databaseConfigSchema, DatabaseConfig } from './types';
|
||||
|
||||
/**
|
||||
* Default database configuration
|
||||
*/
|
||||
const defaultDatabaseConfig: DatabaseConfig = {
|
||||
dragonfly: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
maxRetriesPerRequest: 3
|
||||
},
|
||||
timescaleDB: {
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'stockbot',
|
||||
user: 'postgres'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load database configuration from environment variables
|
||||
*/
|
||||
export function loadDatabaseConfig(): DatabaseConfig {
|
||||
const config: DatabaseConfig = {
|
||||
dragonfly: {
|
||||
host: getEnvVar('DRAGONFLY_HOST') || defaultDatabaseConfig.dragonfly.host,
|
||||
port: getNumericEnvVar('DRAGONFLY_PORT', defaultDatabaseConfig.dragonfly.port),
|
||||
password: getEnvVar('DRAGONFLY_PASSWORD'),
|
||||
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')
|
||||
}
|
||||
};
|
||||
|
||||
return validateConfig(config, databaseConfigSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton database configuration
|
||||
*/
|
||||
export const databaseConfig = loadDatabaseConfig();
|
||||
Loading…
Add table
Add a link
Reference in a new issue