2024-02-22 06:15:16 +00:00
|
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
|
2024-02-23 06:18:00 +00:00
|
|
|
import WorkflowOrchestrator from './workflows/WorkflowOrchestrator';
|
|
|
|
import SessionManager from './rdrama/session/SessionManager';
|
|
|
|
import { CommentParser } from './rdrama/services/CommentParser';
|
2024-02-23 07:02:46 +00:00
|
|
|
import { DatabaseInitializer } from './db/initializeDatabase';
|
2024-02-27 06:39:51 +00:00
|
|
|
import { DatabaseService } from './db/services/Database';
|
|
|
|
import { DatabaseMaintenanceService } from './db/services/DatabaseMaintenance';
|
2024-02-24 06:20:01 +00:00
|
|
|
import { CommentProcessor } from './rdrama/services/CommentProcessor';
|
2024-02-23 06:18:00 +00:00
|
|
|
// Import other necessary services or configurations
|
2024-02-22 06:15:16 +00:00
|
|
|
|
2024-02-23 06:18:00 +00:00
|
|
|
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);
|
|
|
|
|
2024-02-23 07:02:46 +00:00
|
|
|
const databaseInitializer = DatabaseInitializer.getInstance();
|
2024-02-24 06:20:01 +00:00
|
|
|
const db = await databaseInitializer.getDbInstance()
|
2024-02-23 07:02:46 +00:00
|
|
|
if (!db) {
|
|
|
|
throw new Error('Failed to initialize the database.');
|
|
|
|
}
|
2024-02-24 06:20:01 +00:00
|
|
|
const databaseService = new DatabaseService(db)
|
2024-02-27 05:11:00 +00:00
|
|
|
const databaseMaintenance = new DatabaseMaintenanceService(databaseService)
|
|
|
|
console.log('Database Maintenance Start')
|
|
|
|
await databaseMaintenance.runMaintenanceTasks()
|
2024-02-23 07:02:46 +00:00
|
|
|
|
2024-02-23 06:18:00 +00:00
|
|
|
// Initialize services with any required dependencies
|
2024-02-24 06:20:01 +00:00
|
|
|
const commentFetcher = new CommentProcessor(databaseService);
|
2024-02-23 06:18:00 +00:00
|
|
|
const commentParser = new CommentParser();
|
|
|
|
|
|
|
|
// Initialize and start your workflow
|
2024-02-23 07:02:46 +00:00
|
|
|
const workflowOrchestrator = new WorkflowOrchestrator(
|
|
|
|
commentFetcher,
|
2024-02-24 06:20:01 +00:00
|
|
|
commentParser
|
2024-02-23 07:02:46 +00:00
|
|
|
);
|
2024-02-23 06:18:00 +00:00
|
|
|
await workflowOrchestrator.executeWorkflow();
|
|
|
|
}
|
|
|
|
|
|
|
|
startApplication()
|
|
|
|
.then(() => console.log('Application started successfully.'))
|
|
|
|
.catch((error) => console.error('Application failed to start:', error));
|