huge refactor to remove depenencie hell and add typesafe container
This commit is contained in:
parent
28b9822d55
commit
843a7b9b9b
148 changed files with 3603 additions and 2378 deletions
|
|
@ -1,29 +1,29 @@
|
|||
/**
|
||||
* Route factory for data pipeline service
|
||||
* Creates routes with access to the service container
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { healthRoutes } from './health.routes';
|
||||
import { createSyncRoutes } from './sync.routes';
|
||||
import { createEnhancedSyncRoutes } from './enhanced-sync.routes';
|
||||
import { createStatsRoutes } from './stats.routes';
|
||||
|
||||
export function createRoutes(container: IServiceContainer): Hono {
|
||||
const app = new Hono();
|
||||
|
||||
// Add container to context for all routes
|
||||
app.use('*', async (c, next) => {
|
||||
c.set('container', container);
|
||||
await next();
|
||||
});
|
||||
|
||||
// Mount routes
|
||||
app.route('/health', healthRoutes);
|
||||
app.route('/sync', createSyncRoutes(container));
|
||||
app.route('/sync', createEnhancedSyncRoutes(container));
|
||||
app.route('/sync/stats', createStatsRoutes(container));
|
||||
|
||||
return app;
|
||||
}
|
||||
/**
|
||||
* Route factory for data pipeline service
|
||||
* Creates routes with access to the service container
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { createEnhancedSyncRoutes } from './enhanced-sync.routes';
|
||||
import { healthRoutes } from './health.routes';
|
||||
import { createStatsRoutes } from './stats.routes';
|
||||
import { createSyncRoutes } from './sync.routes';
|
||||
|
||||
export function createRoutes(container: IServiceContainer): Hono {
|
||||
const app = new Hono();
|
||||
|
||||
// Add container to context for all routes
|
||||
app.use('*', async (c, next) => {
|
||||
c.set('container', container);
|
||||
await next();
|
||||
});
|
||||
|
||||
// Mount routes
|
||||
app.route('/health', healthRoutes);
|
||||
app.route('/sync', createSyncRoutes(container));
|
||||
app.route('/sync', createEnhancedSyncRoutes(container));
|
||||
app.route('/sync/stats', createStatsRoutes(container));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Hono } from 'hono';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
|
||||
const logger = getLogger('enhanced-sync-routes');
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-all-exchanges', {
|
||||
|
|
@ -40,7 +40,7 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-qm-provider-mappings', {
|
||||
|
|
@ -69,7 +69,7 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-ib-exchanges', {
|
||||
|
|
@ -98,7 +98,7 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-status', {
|
||||
|
|
@ -124,7 +124,7 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('clear-postgresql-data', {
|
||||
|
|
@ -148,4 +148,4 @@ export function createEnhancedSyncRoutes(container: IServiceContainer) {
|
|||
});
|
||||
|
||||
return enhancedSync;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Hono } from 'hono';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
|
||||
const logger = getLogger('stats-routes');
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ export function createStatsRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('get-exchange-stats', {
|
||||
|
|
@ -38,7 +38,7 @@ export function createStatsRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('get-provider-mapping-stats', {
|
||||
|
|
@ -57,4 +57,4 @@ export function createStatsRoutes(container: IServiceContainer) {
|
|||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Hono } from 'hono';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
|
||||
const logger = getLogger('sync-routes');
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-qm-symbols', {
|
||||
|
|
@ -39,7 +39,7 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const exchangesQueue = queueManager.getQueue('exchanges');
|
||||
|
||||
const job = await exchangesQueue.addJob('sync-qm-exchanges', {
|
||||
|
|
@ -65,7 +65,7 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
if (!queueManager) {
|
||||
return c.json({ success: false, error: 'Queue manager not available' }, 503);
|
||||
}
|
||||
|
||||
|
||||
const symbolsQueue = queueManager.getQueue('symbols');
|
||||
|
||||
const job = await symbolsQueue.addJob('sync-symbols-from-provider', {
|
||||
|
|
@ -89,4 +89,4 @@ export function createSyncRoutes(container: IServiceContainer) {
|
|||
});
|
||||
|
||||
return sync;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue