import dotenv from 'dotenv'; dotenv.config(); import WorkflowOrchestrator from './workflows/WorkflowOrchestrator'; import SessionManager from './rdrama/session/SessionManager'; import { CommentFetcher } from './rdrama/services/CommentFetcher'; import { CommentParser } from './rdrama/services/CommentParser'; import { DatabaseInitializer } from './db/initializeDatabase'; // Import other necessary services or configurations async function startApplication() { // Initialize SessionManager or other global configurations const sessionManager = SessionManager.getInstance(); if (!process.env.RDRAMA_API_KEY) { throw new Error('RDRAMA_API_KEY is undefined. Please set this environment variable.'); } sessionManager.setAuthorizationToken(process.env.RDRAMA_API_KEY); const databaseInitializer = DatabaseInitializer.getInstance(); const db = databaseInitializer.getDbInstance() if (!db) { throw new Error('Failed to initialize the database.'); } // Initialize services with any required dependencies const commentFetcher = new CommentFetcher(); const commentParser = new CommentParser(); // Initialize and start your workflow const workflowOrchestrator = new WorkflowOrchestrator( commentFetcher, commentParser, db ); await workflowOrchestrator.executeWorkflow(); } startApplication() .then(() => console.log('Application started successfully.')) .catch((error) => console.error('Application failed to start:', error));