di-refactor coming along
This commit is contained in:
parent
7d9044ab29
commit
60ada5f6a3
20 changed files with 582 additions and 335 deletions
30
apps/web-api/src/migration-helper.ts
Normal file
30
apps/web-api/src/migration-helper.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue