@@ -69,7 +69,7 @@ import etapiSpecialNoteRoutes from "../etapi/special_notes.js";
6969import etapiSpecRoute from "../etapi/spec.js" ;
7070import etapiBackupRoute from "../etapi/backup.js" ;
7171import apiDocsRoute from "./api_docs.js" ;
72- import { apiResultHandler , apiRoute , asyncRoute , route , router , uploadMiddlewareWithErrorHandling } from "./route_api.js" ;
72+ import { apiResultHandler , apiRoute , asyncApiRoute , asyncRoute , route , router , uploadMiddlewareWithErrorHandling } from "./route_api.js" ;
7373
7474const GET = "get" ,
7575 PST = "post" ,
@@ -99,7 +99,7 @@ function register(app: express.Application) {
9999 apiRoute ( GET , '/api/totp/get' , totp . getSecret ) ;
100100
101101 apiRoute ( GET , '/api/oauth/status' , openID . getOAuthStatus ) ;
102- apiRoute ( GET , '/api/oauth/validate' , openID . isTokenValid ) ;
102+ asyncApiRoute ( GET , '/api/oauth/validate' , openID . isTokenValid ) ;
103103
104104 apiRoute ( PST , '/api/totp_recovery/set' , recoveryCodes . setRecoveryCodes ) ;
105105 apiRoute ( PST , '/api/totp_recovery/verify' , recoveryCodes . verifyRecoveryCode ) ;
@@ -129,7 +129,7 @@ function register(app: express.Application) {
129129 apiRoute ( PUT , "/api/notes/:noteId/clone-after/:afterBranchId" , cloningApiRoute . cloneNoteAfter ) ;
130130 route ( PUT , "/api/notes/:noteId/file" , [ auth . checkApiAuthOrElectron , uploadMiddlewareWithErrorHandling , csrfMiddleware ] , filesRoute . updateFile , apiResultHandler ) ;
131131 route ( GET , "/api/notes/:noteId/open" , [ auth . checkApiAuthOrElectron ] , filesRoute . openFile ) ;
132- route (
132+ asyncRoute (
133133 GET ,
134134 "/api/notes/:noteId/open-partial" ,
135135 [ auth . checkApiAuthOrElectron ] ,
@@ -165,7 +165,7 @@ function register(app: express.Application) {
165165 apiRoute ( GET , "/api/attachments/:attachmentId/blob" , attachmentsApiRoute . getAttachmentBlob ) ;
166166 route ( GET , "/api/attachments/:attachmentId/image/:filename" , [ auth . checkApiAuthOrElectron ] , imageRoute . returnAttachedImage ) ;
167167 route ( GET , "/api/attachments/:attachmentId/open" , [ auth . checkApiAuthOrElectron ] , filesRoute . openAttachment ) ;
168- route (
168+ asyncRoute (
169169 GET ,
170170 "/api/attachments/:attachmentId/open-partial" ,
171171 [ auth . checkApiAuthOrElectron ] ,
@@ -194,7 +194,7 @@ function register(app: express.Application) {
194194 route ( GET , "/api/revisions/:revisionId/download" , [ auth . checkApiAuthOrElectron ] , revisionsApiRoute . downloadRevision ) ;
195195
196196 route ( GET , "/api/branches/:branchId/export/:type/:format/:version/:taskId" , [ auth . checkApiAuthOrElectron ] , exportRoute . exportBranch ) ;
197- route ( PST , "/api/notes/:parentNoteId/notes-import" , [ auth . checkApiAuthOrElectron , uploadMiddlewareWithErrorHandling , csrfMiddleware ] , importRoute . importNotesToBranch , apiResultHandler ) ;
197+ asyncRoute ( PST , "/api/notes/:parentNoteId/notes-import" , [ auth . checkApiAuthOrElectron , uploadMiddlewareWithErrorHandling , csrfMiddleware ] , importRoute . importNotesToBranch , apiResultHandler ) ;
198198 route ( PST , "/api/notes/:parentNoteId/attachments-import" , [ auth . checkApiAuthOrElectron , uploadMiddlewareWithErrorHandling , csrfMiddleware ] , importRoute . importAttachmentsToNote , apiResultHandler ) ;
199199
200200 apiRoute ( GET , "/api/notes/:noteId/attributes" , attributesRoute . getEffectiveNoteAttributes ) ;
@@ -223,8 +223,8 @@ function register(app: express.Application) {
223223 apiRoute ( PST , "/api/password/change" , passwordApiRoute . changePassword ) ;
224224 apiRoute ( PST , "/api/password/reset" , passwordApiRoute . resetPassword ) ;
225225
226- apiRoute ( PST , "/api/sync/test" , syncApiRoute . testSync ) ;
227- apiRoute ( PST , "/api/sync/now" , syncApiRoute . syncNow ) ;
226+ asyncApiRoute ( PST , "/api/sync/test" , syncApiRoute . testSync ) ;
227+ asyncApiRoute ( PST , "/api/sync/now" , syncApiRoute . syncNow ) ;
228228 apiRoute ( PST , "/api/sync/fill-entity-changes" , syncApiRoute . fillEntityChanges ) ;
229229 apiRoute ( PST , "/api/sync/force-full-sync" , syncApiRoute . forceFullSync ) ;
230230 route ( GET , "/api/sync/check" , [ auth . checkApiAuth ] , syncApiRoute . checkSync , apiResultHandler ) ;
@@ -277,21 +277,21 @@ function register(app: express.Application) {
277277 const clipperMiddleware = isElectron ? [ ] : [ auth . checkEtapiToken ] ;
278278
279279 route ( GET , "/api/clipper/handshake" , clipperMiddleware , clipperRoute . handshake , apiResultHandler ) ;
280- route ( PST , "/api/clipper/clippings" , clipperMiddleware , clipperRoute . addClipping , apiResultHandler ) ;
281- route ( PST , "/api/clipper/notes" , clipperMiddleware , clipperRoute . createNote , apiResultHandler ) ;
280+ asyncRoute ( PST , "/api/clipper/clippings" , clipperMiddleware , clipperRoute . addClipping , apiResultHandler ) ;
281+ asyncRoute ( PST , "/api/clipper/notes" , clipperMiddleware , clipperRoute . createNote , apiResultHandler ) ;
282282 route ( PST , "/api/clipper/open/:noteId" , clipperMiddleware , clipperRoute . openNote , apiResultHandler ) ;
283- route ( GET , "/api/clipper/notes-by-url/:noteUrl" , clipperMiddleware , clipperRoute . findNotesByUrl , apiResultHandler ) ;
284-
285- apiRoute ( GET , "/api/special-notes/inbox/:date" , specialNotesRoute . getInboxNote ) ;
286- apiRoute ( GET , "/api/special-notes/days/:date" , specialNotesRoute . getDayNote ) ;
287- apiRoute ( GET , "/api/special-notes/week-first-day/:date" , specialNotesRoute . getWeekFirstDayNote ) ;
288- apiRoute ( GET , "/api/special-notes/weeks/:week" , specialNotesRoute . getWeekNote ) ;
289- apiRoute ( GET , "/api/special-notes/months/:month" , specialNotesRoute . getMonthNote ) ;
290- apiRoute ( GET , "/api/special-notes/quarters/:quarter" , specialNotesRoute . getQuarterNote ) ;
283+ asyncRoute ( GET , "/api/clipper/notes-by-url/:noteUrl" , clipperMiddleware , clipperRoute . findNotesByUrl , apiResultHandler ) ;
284+
285+ asyncApiRoute ( GET , "/api/special-notes/inbox/:date" , specialNotesRoute . getInboxNote ) ;
286+ asyncApiRoute ( GET , "/api/special-notes/days/:date" , specialNotesRoute . getDayNote ) ;
287+ asyncApiRoute ( GET , "/api/special-notes/week-first-day/:date" , specialNotesRoute . getWeekFirstDayNote ) ;
288+ asyncApiRoute ( GET , "/api/special-notes/weeks/:week" , specialNotesRoute . getWeekNote ) ;
289+ asyncApiRoute ( GET , "/api/special-notes/months/:month" , specialNotesRoute . getMonthNote ) ;
290+ asyncApiRoute ( GET , "/api/special-notes/quarters/:quarter" , specialNotesRoute . getQuarterNote ) ;
291291 apiRoute ( GET , "/api/special-notes/years/:year" , specialNotesRoute . getYearNote ) ;
292292 apiRoute ( GET , "/api/special-notes/notes-for-month/:month" , specialNotesRoute . getDayNotesForMonth ) ;
293293 apiRoute ( PST , "/api/special-notes/sql-console" , specialNotesRoute . createSqlConsole ) ;
294- apiRoute ( PST , "/api/special-notes/save-sql-console" , specialNotesRoute . saveSqlConsole ) ;
294+ asyncApiRoute ( PST , "/api/special-notes/save-sql-console" , specialNotesRoute . saveSqlConsole ) ;
295295 apiRoute ( PST , "/api/special-notes/search-note" , specialNotesRoute . createSearchNote ) ;
296296 apiRoute ( PST , "/api/special-notes/save-search-note" , specialNotesRoute . saveSearchNote ) ;
297297 apiRoute ( PST , "/api/special-notes/launchers/:noteId/reset" , specialNotesRoute . resetLauncher ) ;
@@ -328,17 +328,17 @@ function register(app: express.Application) {
328328
329329 // no CSRF since this is called from android app
330330 route ( PST , "/api/sender/login" , [ loginRateLimiter ] , loginApiRoute . token , apiResultHandler ) ;
331- route ( PST , "/api/sender/image" , [ auth . checkEtapiToken , uploadMiddlewareWithErrorHandling ] , senderRoute . uploadImage , apiResultHandler ) ;
332- route ( PST , "/api/sender/note" , [ auth . checkEtapiToken ] , senderRoute . saveNote , apiResultHandler ) ;
331+ asyncRoute ( PST , "/api/sender/image" , [ auth . checkEtapiToken , uploadMiddlewareWithErrorHandling ] , senderRoute . uploadImage , apiResultHandler ) ;
332+ asyncRoute ( PST , "/api/sender/note" , [ auth . checkEtapiToken ] , senderRoute . saveNote , apiResultHandler ) ;
333333
334334 apiRoute ( GET , "/api/keyboard-actions" , keysRoute . getKeyboardActions ) ;
335335 apiRoute ( GET , "/api/keyboard-shortcuts-for-notes" , keysRoute . getShortcutsForNotes ) ;
336336
337337 apiRoute ( PST , "/api/relation-map" , relationMapApiRoute . getRelationMap ) ;
338338 apiRoute ( PST , "/api/notes/erase-deleted-notes-now" , notesApiRoute . eraseDeletedNotesNow ) ;
339339 apiRoute ( PST , "/api/notes/erase-unused-attachments-now" , notesApiRoute . eraseUnusedAttachmentsNow ) ;
340- apiRoute ( GET , "/api/similar-notes/:noteId" , similarNotesRoute . getSimilarNotes ) ;
341- apiRoute ( GET , "/api/backend-log" , backendLogRoute . getBackendLog ) ;
340+ asyncApiRoute ( GET , "/api/similar-notes/:noteId" , similarNotesRoute . getSimilarNotes ) ;
341+ asyncApiRoute ( GET , "/api/backend-log" , backendLogRoute . getBackendLog ) ;
342342 apiRoute ( GET , "/api/stats/note-size/:noteId" , statsRoute . getNoteSize ) ;
343343 apiRoute ( GET , "/api/stats/subtree-size/:noteId" , statsRoute . getSubtreeSize ) ;
344344 apiRoute ( PST , "/api/delete-notes-preview" , notesApiRoute . getDeleteNotesPreview ) ;
@@ -366,42 +366,42 @@ function register(app: express.Application) {
366366 etapiBackupRoute . register ( router ) ;
367367
368368 // LLM Chat API
369- apiRoute ( PST , "/api/llm/chat" , llmRoute . createSession ) ;
370- apiRoute ( GET , "/api/llm/chat" , llmRoute . listSessions ) ;
371- apiRoute ( GET , "/api/llm/chat/:sessionId" , llmRoute . getSession ) ;
372- apiRoute ( PATCH , "/api/llm/chat/:sessionId" , llmRoute . updateSession ) ;
373- apiRoute ( DEL , "/api/llm/chat/:chatNoteId" , llmRoute . deleteSession ) ;
374- apiRoute ( PST , "/api/llm/chat/:chatNoteId/messages" , llmRoute . sendMessage ) ;
375- apiRoute ( PST , "/api/llm/chat/:chatNoteId/messages/stream" , llmRoute . streamMessage ) ;
369+ asyncApiRoute ( PST , "/api/llm/chat" , llmRoute . createSession ) ;
370+ asyncApiRoute ( GET , "/api/llm/chat" , llmRoute . listSessions ) ;
371+ asyncApiRoute ( GET , "/api/llm/chat/:sessionId" , llmRoute . getSession ) ;
372+ asyncApiRoute ( PATCH , "/api/llm/chat/:sessionId" , llmRoute . updateSession ) ;
373+ asyncApiRoute ( DEL , "/api/llm/chat/:chatNoteId" , llmRoute . deleteSession ) ;
374+ asyncApiRoute ( PST , "/api/llm/chat/:chatNoteId/messages" , llmRoute . sendMessage ) ;
375+ asyncApiRoute ( PST , "/api/llm/chat/:chatNoteId/messages/stream" , llmRoute . streamMessage ) ;
376376
377377 // LLM index management endpoints - reorganized for REST principles
378- apiRoute ( GET , "/api/llm/indexes/stats" , llmRoute . getIndexStats ) ;
379- apiRoute ( PST , "/api/llm/indexes" , llmRoute . startIndexing ) ; // Create index process
380- apiRoute ( GET , "/api/llm/indexes/failed" , llmRoute . getFailedIndexes ) ;
381- apiRoute ( PUT , "/api/llm/indexes/notes/:noteId" , llmRoute . retryFailedIndex ) ; // Update index for note
382- apiRoute ( PUT , "/api/llm/indexes/failed" , llmRoute . retryAllFailedIndexes ) ; // Update all failed indexes
383- apiRoute ( GET , "/api/llm/indexes/notes/similar" , llmRoute . findSimilarNotes ) ; // Get similar notes
384- apiRoute ( GET , "/api/llm/indexes/context" , llmRoute . generateQueryContext ) ; // Get context
385- apiRoute ( PST , "/api/llm/indexes/notes/:noteId" , llmRoute . indexNote ) ; // Create index for specific note
378+ asyncApiRoute ( GET , "/api/llm/indexes/stats" , llmRoute . getIndexStats ) ;
379+ asyncApiRoute ( PST , "/api/llm/indexes" , llmRoute . startIndexing ) ; // Create index process
380+ asyncApiRoute ( GET , "/api/llm/indexes/failed" , llmRoute . getFailedIndexes ) ;
381+ asyncApiRoute ( PUT , "/api/llm/indexes/notes/:noteId" , llmRoute . retryFailedIndex ) ; // Update index for note
382+ asyncApiRoute ( PUT , "/api/llm/indexes/failed" , llmRoute . retryAllFailedIndexes ) ; // Update all failed indexes
383+ asyncApiRoute ( GET , "/api/llm/indexes/notes/similar" , llmRoute . findSimilarNotes ) ; // Get similar notes
384+ asyncApiRoute ( GET , "/api/llm/indexes/context" , llmRoute . generateQueryContext ) ; // Get context
385+ asyncApiRoute ( PST , "/api/llm/indexes/notes/:noteId" , llmRoute . indexNote ) ; // Create index for specific note
386386
387387 // LLM embeddings endpoints
388- apiRoute ( GET , "/api/llm/embeddings/similar/:noteId" , embeddingsRoute . findSimilarNotes ) ;
389- apiRoute ( PST , "/api/llm/embeddings/search" , embeddingsRoute . searchByText ) ;
390- apiRoute ( GET , "/api/llm/embeddings/providers" , embeddingsRoute . getProviders ) ;
391- apiRoute ( PATCH , "/api/llm/embeddings/providers/:providerId" , embeddingsRoute . updateProvider ) ;
392- apiRoute ( PST , "/api/llm/embeddings/reprocess" , embeddingsRoute . reprocessAllNotes ) ;
393- apiRoute ( GET , "/api/llm/embeddings/queue-status" , embeddingsRoute . getQueueStatus ) ;
394- apiRoute ( GET , "/api/llm/embeddings/stats" , embeddingsRoute . getEmbeddingStats ) ;
395- apiRoute ( GET , "/api/llm/embeddings/failed" , embeddingsRoute . getFailedNotes ) ;
396- apiRoute ( PST , "/api/llm/embeddings/retry/:noteId" , embeddingsRoute . retryFailedNote ) ;
397- apiRoute ( PST , "/api/llm/embeddings/retry-all-failed" , embeddingsRoute . retryAllFailedNotes ) ;
398- apiRoute ( PST , "/api/llm/embeddings/rebuild-index" , embeddingsRoute . rebuildIndex ) ;
399- apiRoute ( GET , "/api/llm/embeddings/index-rebuild-status" , embeddingsRoute . getIndexRebuildStatus ) ;
388+ asyncApiRoute ( GET , "/api/llm/embeddings/similar/:noteId" , embeddingsRoute . findSimilarNotes ) ;
389+ asyncApiRoute ( PST , "/api/llm/embeddings/search" , embeddingsRoute . searchByText ) ;
390+ asyncApiRoute ( GET , "/api/llm/embeddings/providers" , embeddingsRoute . getProviders ) ;
391+ asyncApiRoute ( PATCH , "/api/llm/embeddings/providers/:providerId" , embeddingsRoute . updateProvider ) ;
392+ asyncApiRoute ( PST , "/api/llm/embeddings/reprocess" , embeddingsRoute . reprocessAllNotes ) ;
393+ asyncApiRoute ( GET , "/api/llm/embeddings/queue-status" , embeddingsRoute . getQueueStatus ) ;
394+ asyncApiRoute ( GET , "/api/llm/embeddings/stats" , embeddingsRoute . getEmbeddingStats ) ;
395+ asyncApiRoute ( GET , "/api/llm/embeddings/failed" , embeddingsRoute . getFailedNotes ) ;
396+ asyncApiRoute ( PST , "/api/llm/embeddings/retry/:noteId" , embeddingsRoute . retryFailedNote ) ;
397+ asyncApiRoute ( PST , "/api/llm/embeddings/retry-all-failed" , embeddingsRoute . retryAllFailedNotes ) ;
398+ asyncApiRoute ( PST , "/api/llm/embeddings/rebuild-index" , embeddingsRoute . rebuildIndex ) ;
399+ asyncApiRoute ( GET , "/api/llm/embeddings/index-rebuild-status" , embeddingsRoute . getIndexRebuildStatus ) ;
400400
401401 // LLM provider endpoints - moved under /api/llm/providers hierarchy
402- apiRoute ( GET , "/api/llm/providers/ollama/models" , ollamaRoute . listModels ) ;
403- apiRoute ( GET , "/api/llm/providers/openai/models" , openaiRoute . listModels ) ;
404- apiRoute ( GET , "/api/llm/providers/anthropic/models" , anthropicRoute . listModels ) ;
402+ asyncApiRoute ( GET , "/api/llm/providers/ollama/models" , ollamaRoute . listModels ) ;
403+ asyncApiRoute ( GET , "/api/llm/providers/openai/models" , openaiRoute . listModels ) ;
404+ asyncApiRoute ( GET , "/api/llm/providers/anthropic/models" , anthropicRoute . listModels ) ;
405405
406406 // API Documentation
407407 apiDocsRoute ( app ) ;
0 commit comments