(plugin: TaskNotesPlugin)
| 244 | } |
| 245 | |
| 246 | export async function initializeHTTPAPI(plugin: TaskNotesPlugin): Promise<void> { |
| 247 | if (Platform.isMobile || !plugin.settings.enableAPI) { |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | try { |
| 252 | const { HTTPAPIService } = await import("../services/HTTPAPIService"); |
| 253 | |
| 254 | plugin.apiService = new HTTPAPIService( |
| 255 | plugin, |
| 256 | plugin.taskService, |
| 257 | plugin.filterService, |
| 258 | plugin.cacheManager |
| 259 | ); |
| 260 | |
| 261 | plugin.taskService.setWebhookNotifier(plugin.apiService); |
| 262 | plugin.pomodoroService.setWebhookNotifier(plugin.apiService); |
| 263 | await plugin.apiService.start(); |
| 264 | showNotice(`TaskNotes API started on port ${plugin.apiService.getPort()}`); |
| 265 | } catch (error) { |
| 266 | tasknotesLogger.error("Failed to initialize HTTP API:", { |
| 267 | category: "provider", |
| 268 | operation: "initialize-http-api", |
| 269 | error: error, |
| 270 | }); |
| 271 | showNotice("Failed to start tasknotes API server. Check console for details."); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | export async function initializeAfterLayoutReady(plugin: TaskNotesPlugin): Promise<void> { |
| 276 | if (plugin.initializationComplete) { |
no test coverage detected