refactored monorepo for more projects
This commit is contained in:
parent
4632c174dc
commit
9492f1b15e
180 changed files with 1438 additions and 424 deletions
|
|
@ -73,26 +73,24 @@ export class ServiceContainerBuilder {
|
|||
|
||||
private applyServiceOptions(config: Partial<AppConfig>): AppConfig {
|
||||
return {
|
||||
redis: {
|
||||
redis: config.redis || {
|
||||
enabled: this.options.enableCache ?? true,
|
||||
host: config.redis?.host || 'localhost',
|
||||
port: config.redis?.port || 6379,
|
||||
password: config.redis?.password,
|
||||
username: config.redis?.username,
|
||||
db: config.redis?.db || 0,
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
db: 0,
|
||||
},
|
||||
mongodb: {
|
||||
mongodb: config.mongodb || {
|
||||
enabled: this.options.enableMongoDB ?? true,
|
||||
uri: config.mongodb?.uri || '',
|
||||
database: config.mongodb?.database || '',
|
||||
uri: '',
|
||||
database: '',
|
||||
},
|
||||
postgres: {
|
||||
postgres: config.postgres || {
|
||||
enabled: this.options.enablePostgres ?? true,
|
||||
host: config.postgres?.host || 'localhost',
|
||||
port: config.postgres?.port || 5432,
|
||||
database: config.postgres?.database || '',
|
||||
user: config.postgres?.user || '',
|
||||
password: config.postgres?.password || '',
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'postgres',
|
||||
user: 'postgres',
|
||||
password: 'postgres',
|
||||
},
|
||||
questdb: this.options.enableQuestDB ? (config.questdb || {
|
||||
enabled: true,
|
||||
|
|
@ -104,7 +102,19 @@ export class ServiceContainerBuilder {
|
|||
}) : undefined,
|
||||
proxy: this.options.enableProxy ? (config.proxy || { cachePrefix: 'proxy:', ttl: 3600 }) : undefined,
|
||||
browser: this.options.enableBrowser ? (config.browser || { headless: true, timeout: 30000 }) : undefined,
|
||||
queue: this.options.enableQueue ? { enabled: this.options.enableQueue } : undefined,
|
||||
queue: this.options.enableQueue ? (config.queue || {
|
||||
enabled: true,
|
||||
workers: 1,
|
||||
concurrency: 1,
|
||||
enableScheduledJobs: true,
|
||||
delayWorkerStart: false,
|
||||
defaultJobOptions: {
|
||||
attempts: 3,
|
||||
backoff: { type: 'exponential' as const, delay: 1000 },
|
||||
removeOnComplete: 100,
|
||||
removeOnFail: 50,
|
||||
}
|
||||
}) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -133,8 +143,8 @@ export class ServiceContainerBuilder {
|
|||
}
|
||||
|
||||
private transformStockBotConfig(config: AppConfig | StockBotAppConfig): Partial<AppConfig> {
|
||||
// If it's already in the new format, return as is
|
||||
if ('redis' in config) {
|
||||
// If it's already in the new format (has redis AND postgres at top level), return as is
|
||||
if ('redis' in config && 'postgres' in config && 'mongodb' in config) {
|
||||
return config as AppConfig;
|
||||
}
|
||||
|
||||
|
|
@ -149,18 +159,17 @@ export class ServiceContainerBuilder {
|
|||
db: stockBotConfig.database.dragonfly.db || 0,
|
||||
} : undefined,
|
||||
mongodb: stockBotConfig.database?.mongodb ? {
|
||||
enabled: true,
|
||||
uri: stockBotConfig.database.mongodb.uri ||
|
||||
`mongodb://${stockBotConfig.database.mongodb.user || ''}:${stockBotConfig.database.mongodb.password || ''}@${stockBotConfig.database.mongodb.host || 'localhost'}:${stockBotConfig.database.mongodb.port || 27017}/${stockBotConfig.database.mongodb.database || 'test'}?authSource=${stockBotConfig.database.mongodb.authSource || 'admin'}`,
|
||||
database: stockBotConfig.database.mongodb.database || 'test',
|
||||
enabled: stockBotConfig.database.mongodb.enabled ?? true,
|
||||
uri: stockBotConfig.database.mongodb.uri,
|
||||
database: stockBotConfig.database.mongodb.database,
|
||||
} : undefined,
|
||||
postgres: stockBotConfig.database?.postgres ? {
|
||||
enabled: true,
|
||||
host: stockBotConfig.database.postgres.host || 'localhost',
|
||||
port: stockBotConfig.database.postgres.port || 5432,
|
||||
database: stockBotConfig.database.postgres.database || 'test',
|
||||
user: stockBotConfig.database.postgres.user || 'test',
|
||||
password: stockBotConfig.database.postgres.password || 'test',
|
||||
enabled: stockBotConfig.database.postgres.enabled ?? true,
|
||||
host: stockBotConfig.database.postgres.host,
|
||||
port: stockBotConfig.database.postgres.port,
|
||||
database: stockBotConfig.database.postgres.database,
|
||||
user: stockBotConfig.database.postgres.user,
|
||||
password: stockBotConfig.database.postgres.password,
|
||||
} : undefined,
|
||||
questdb: stockBotConfig.database?.questdb ? {
|
||||
enabled: true,
|
||||
|
|
@ -170,6 +179,9 @@ export class ServiceContainerBuilder {
|
|||
influxPort: stockBotConfig.database.questdb.ilpPort || 9009,
|
||||
database: stockBotConfig.database.questdb.database || 'questdb',
|
||||
} : undefined,
|
||||
queue: stockBotConfig.queue,
|
||||
browser: stockBotConfig.browser,
|
||||
proxy: stockBotConfig.proxy,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue