diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 387460cb..36bfd3d1 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -43,40 +43,39 @@ export class App { async initDatabase() { // Initialize database - this.AppDataSource.initialize() - .then(async () => { - logger.info('📦 [server]: Data Source is initializing...') + try { + await this.AppDataSource.initialize() + logger.info('📦 [server]: Data Source is initializing...') - // Run Migrations Scripts - await this.AppDataSource.runMigrations({ transaction: 'each' }) + // Run Migrations Scripts + await this.AppDataSource.runMigrations({ transaction: 'each' }) - // Initialize nodes pool - this.nodesPool = new NodesPool() - await this.nodesPool.initialize() + // Initialize nodes pool + this.nodesPool = new NodesPool() + await this.nodesPool.initialize() - // Initialize chatflow pool - this.chatflowPool = new ChatflowPool() + // Initialize chatflow pool + this.chatflowPool = new ChatflowPool() - // Initialize API keys - await getAPIKeys() + // Initialize API keys + await getAPIKeys() - // Initialize encryption key - await getEncryptionKey() + // Initialize encryption key + await getEncryptionKey() - // Initialize Rate Limit - const AllChatFlow: IChatFlow[] = await getAllChatFlow() - await initializeRateLimiter(AllChatFlow) + // Initialize Rate Limit + const AllChatFlow: IChatFlow[] = await getAllChatFlow() + await initializeRateLimiter(AllChatFlow) - // Initialize cache pool - this.cachePool = new CachePool() + // Initialize cache pool + this.cachePool = new CachePool() - // Initialize telemetry - this.telemetry = new Telemetry() - logger.info('📦 [server]: Data Source has been initialized!') - }) - .catch((err) => { - logger.error('❌ [server]: Error during Data Source initialization:', err) - }) + // Initialize telemetry + this.telemetry = new Telemetry() + logger.info('📦 [server]: Data Source has been initialized!') + } catch (error) { + logger.error('❌ [server]: Error during Data Source initialization:', error) + } } async config(socketIO?: Server) {