From 3973fa08f703d788bf56de21a7e451c03ea5c560 Mon Sep 17 00:00:00 2001 From: Nexus Dev Date: Sat, 4 Apr 2026 03:14:08 +0000 Subject: [PATCH] feat(38-01): wire telegramService + telegramRoutes into app.ts - Import telegramService, telegramRoutes, nexusSettingsService - Mount /telegram routes under /api prefix - Conditionally start Telegram bot on boot if telegramToken is configured - Token route restarts bot after saving new token --- server/src/app.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/app.ts b/server/src/app.ts index 8c705616..a724af0e 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -33,6 +33,9 @@ import { assistantHandoffRoutes } from "./routes/assistant-handoff.js"; import { chatFileRoutes } from "./routes/chat-files.js"; import { nexusSettingsRoutes } from "./routes/nexus-settings.js"; import { voiceRoutes } from "./routes/voice.js"; +import { telegramService } from "./services/telegram.js"; +import { telegramRoutes } from "./routes/telegram.js"; +import { nexusSettingsService } from "./services/nexus-settings.js"; import { pluginRoutes } from "./routes/plugins.js"; import { pluginUiStaticRoutes } from "./routes/plugin-ui-static.js"; import { applyUiBranding } from "./ui-branding.js"; @@ -172,6 +175,11 @@ export async function createApp( api.use(chatFileRoutes(db, opts.storageService)); api.use(nexusSettingsRoutes()); api.use(voiceRoutes()); + + // Telegram bridge — create service instance and mount routes + const tg = telegramService(db); + api.use(telegramRoutes(db, tg)); + const hostServicesDisposers = new Map void>(); const workerManager = createPluginWorkerManager(); const pluginRegistry = pluginRegistryService(db); @@ -333,5 +341,15 @@ export async function createApp( void flushPluginLogBuffer(); }); + // Conditionally start telegram bot if token is configured + { + const settings = await nexusSettingsService().get(); + if (settings.telegramToken) { + tg.start(settings.telegramToken).catch((err) => { + logger.error({ err }, "Failed to start Telegram bot"); + }); + } + } + return app; }