di-refactor coming along

This commit is contained in:
Boki 2025-06-22 18:14:34 -04:00
parent 7d9044ab29
commit 60ada5f6a3
20 changed files with 582 additions and 335 deletions

View file

@ -0,0 +1,30 @@
/**
* Temporary migration helper for web-api service
* Provides backward compatibility while migrating to DI container
*
* TODO: Remove this file once all routes and services are migrated to use ServiceContainer
*/
import type { ServiceContainer } from '@stock-bot/di';
import type { MongoDBClient } from '@stock-bot/mongodb';
import type { PostgreSQLClient } from '@stock-bot/postgres';
let containerInstance: ServiceContainer | null = null;
export function setContainerForMigration(container: ServiceContainer): void {
containerInstance = container;
}
export function getMongoDBClient(): MongoDBClient {
if (!containerInstance) {
throw new Error('Container not initialized. This is a migration helper - please update the service to accept ServiceContainer parameter');
}
return containerInstance.mongodb;
}
export function getPostgreSQLClient(): PostgreSQLClient {
if (!containerInstance) {
throw new Error('Container not initialized. This is a migration helper - please update the service to accept ServiceContainer parameter');
}
return containerInstance.postgres;
}