/** * Data Pipeline Service * Simplified entry point using ServiceApplication framework */ import { createHttpSecurity, httpSecurityOptions, ServiceApplication } from '@stock-bot/di'; import { getLogger } from '@stock-bot/logger'; import { initializeStockConfig } from '@stock-bot/stock-config'; import { createRoutes } from './routes/create-routes'; // Local imports import { initializeAllHandlers } from './handlers'; // Initialize configuration with service-specific overrides const config = initializeStockConfig('dataPipeline', { mongoReadOnly: true }); const security = createHttpSecurity({ ...httpSecurityOptions(), environment: config.environment }); // Log the full configuration const logger = getLogger('data-pipeline'); logger.info('Service configuration:', { service: 'data-pipeline', port: config.service.port, environment: config.environment, }); // Create service application const app = new ServiceApplication( config, { serviceName: 'data-pipeline', hostname: security.hostname, enableHandlers: true, enableScheduledJobs: config.queue?.enableScheduledJobs ?? false, corsConfig: { origin: '*', allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'], allowHeaders: ['Content-Type', 'Authorization'], credentials: false, }, serviceMetadata: { version: '1.0.0', description: 'Data processing and transformation pipeline', endpoints: { health: '/health', operations: '/api/operations', }, }, }, { // Custom lifecycle hooks onAppReady: app => security.mount(app), onStarted: _port => { const logger = getLogger('data-pipeline'); logger.info('Data pipeline service startup initiated with ServiceApplication framework'); }, } ); // Container factory function async function createContainer(config: import('@stock-bot/config').UnifiedAppConfig) { const { ServiceContainerBuilder } = await import('@stock-bot/di'); const builder = new ServiceContainerBuilder(); const container = await builder .withConfig(config) .withOptions({ enableQuestDB: false, // Disabled for now due to auth issues // Data pipeline reads raw ingestion data from MongoDB (read-only) and writes master records to PostgreSQL enableMongoDB: true, mongoReadOnly: true, enablePostgres: true, enableCache: true, enableQueue: true, delayWorkerStart: true, enableBrowser: false, // Data pipeline doesn't need browser enableProxy: false, // Data pipeline doesn't need proxy skipInitialization: false, // Let builder handle initialization }) .build(); return container; } // Start the service app.start(createContainer, createRoutes, initializeAllHandlers).catch(error => { const logger = getLogger('data-pipeline'); logger.fatal('Failed to start data pipeline service', { error }); process.exit(1); });