removed old di fully and replaced with awilix
This commit is contained in:
parent
d8ae0cb3c5
commit
c6c55e2979
9 changed files with 200 additions and 747 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { IDataIngestionServices } from '@stock-bot/di';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { exchangeRoutes } from './exchange.routes';
|
||||
import { healthRoutes } from './health.routes';
|
||||
import { queueRoutes } from './queue.routes';
|
||||
|
|
@ -11,7 +11,7 @@ import { queueRoutes } from './queue.routes';
|
|||
/**
|
||||
* Creates all routes with access to type-safe services
|
||||
*/
|
||||
export function createRoutes(services: IDataIngestionServices): Hono {
|
||||
export function createRoutes(services: IServiceContainer): Hono {
|
||||
const app = new Hono();
|
||||
|
||||
// Mount routes that don't need services
|
||||
|
|
@ -30,19 +30,19 @@ export function createRoutes(services: IDataIngestionServices): Hono {
|
|||
// Add a new endpoint to test the improved DI
|
||||
app.get('/api/di-test', async (c) => {
|
||||
try {
|
||||
const services = c.get('services') as IDataIngestionServices;
|
||||
const services = c.get('services') as IServiceContainer;
|
||||
|
||||
// Test MongoDB connection
|
||||
const mongoStats = services.mongodb.getPoolMetrics?.() || { status: 'connected' };
|
||||
const mongoStats = services.mongodb?.getPoolMetrics?.() || { status: services.mongodb ? 'connected' : 'disabled' };
|
||||
|
||||
// Test PostgreSQL connection
|
||||
const pgConnected = services.postgres.connected;
|
||||
const pgConnected = services.postgres?.connected || false;
|
||||
|
||||
// Test cache
|
||||
const cacheReady = services.cache.isReady();
|
||||
const cacheReady = services.cache?.isReady() || false;
|
||||
|
||||
// Test queue
|
||||
const queueStats = services.queue.getGlobalStats();
|
||||
const queueStats = services.queue?.getGlobalStats() || { status: 'disabled' };
|
||||
|
||||
return c.json({
|
||||
success: true,
|
||||
|
|
@ -56,6 +56,7 @@ export function createRoutes(services: IDataIngestionServices): Hono {
|
|||
timestamp: new Date().toISOString()
|
||||
});
|
||||
} catch (error) {
|
||||
const services = c.get('services') as IServiceContainer;
|
||||
services.logger.error('DI test endpoint failed', { error });
|
||||
return c.json({
|
||||
success: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue