fixed up di
This commit is contained in:
parent
d63025de90
commit
8550b1de57
5 changed files with 19 additions and 56 deletions
|
|
@ -7,7 +7,7 @@ import { Browser } from '@stock-bot/browser';
|
|||
import { createCache, type CacheProvider } from '@stock-bot/cache';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { createMongoDBClient } from '@stock-bot/mongodb';
|
||||
import { MongoDBClient } from '@stock-bot/mongodb';
|
||||
import { createPostgreSQLClient } from '@stock-bot/postgres';
|
||||
import { ProxyManager } from '@stock-bot/proxy';
|
||||
import { createQuestDBClient } from '@stock-bot/questdb';
|
||||
|
|
@ -90,22 +90,9 @@ export function createServiceContainer(config: AppConfig): AwilixContainer {
|
|||
);
|
||||
// Note: initialization happens in initializeServices function
|
||||
return manager;
|
||||
}).singleton(),
|
||||
|
||||
|
||||
// MongoDB client with injected logger
|
||||
}).singleton(), // MongoDB client with injected dependencies
|
||||
mongoClient: asFunction(({ mongoConfig, logger }) => {
|
||||
// Parse MongoDB URI to extract host and port
|
||||
const url = new URL(mongoConfig.uri);
|
||||
return createMongoDBClient(
|
||||
{
|
||||
uri: mongoConfig.uri,
|
||||
host: url.hostname,
|
||||
port: parseInt(url.port || '27017'),
|
||||
database: mongoConfig.database,
|
||||
},
|
||||
logger
|
||||
);
|
||||
return new MongoDBClient(mongoConfig, logger);
|
||||
}).singleton(),
|
||||
|
||||
postgresClient: asFunction(({ postgresConfig, logger }) => {
|
||||
|
|
|
|||
|
|
@ -32,11 +32,9 @@ export class ConnectionFactory implements IConnectionFactory {
|
|||
this.logger.info('Creating MongoDB connection pool', {
|
||||
name: poolConfig.name,
|
||||
poolSize: poolConfig.poolSize,
|
||||
});
|
||||
|
||||
try {
|
||||
}); try {
|
||||
// Dynamic import to avoid circular dependency
|
||||
const { createMongoDBClient } = await import('@stock-bot/mongodb');
|
||||
const { MongoDBClient } = await import('@stock-bot/mongodb');
|
||||
|
||||
const events = {
|
||||
onConnect: () => {
|
||||
|
|
@ -50,7 +48,7 @@ export class ConnectionFactory implements IConnectionFactory {
|
|||
},
|
||||
};
|
||||
|
||||
const client = createMongoDBClient(poolConfig.config as any, events);
|
||||
const client = new MongoDBClient(poolConfig.config as any, this.logger, events);
|
||||
|
||||
await client.connect();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue