Integrate sync queue system and device cap API

- Start queue processor as background goroutine
- Initialize and register queue handler
- Add queue management routes (7 endpoints)
- Update KOReader handler to use checkpoint sync mode
- Add device cap management route (PUT /api/auth/users/:id/max-devices)
- Register all new endpoints with proper middleware
This commit is contained in:
2026-01-31 13:06:56 -05:00
parent 50c632babf
commit a7f2b83bdd
2 changed files with 116 additions and 4 deletions
+19 -1
View File
@@ -57,9 +57,14 @@ func main() {
connManager := sync.NewConnectionManager()
connManager.StartCleanupTask()
koreaderHandler := handlers.NewKOReaderHandler(queries, connManager)
// Create sync queue processor
queueProcessor := sync.NewSyncQueueProcessor(queries)
go queueProcessor.Start(context.Background())
koreaderHandler := handlers.NewKOReaderHandler(queries, connManager, queueProcessor)
wsHandler := handlers.NewWSHandler(queries, connManager, cfg.JWTSecret, deviceAuthMiddleware)
conflictHandler := handlers.NewConflictHandler(queries, connManager)
queueHandler := handlers.NewQueueHandler(queries, queueProcessor)
e := echo.New()
@@ -147,6 +152,7 @@ func main() {
// Admin-only routes for user and folder management
admin := protected.Group("/auth", handlers.AdminMiddleware)
admin.GET("/users", authHandler.ListUsers)
admin.PUT("/users/:id/max-devices", authHandler.UpdateUserMaxDevices)
// Library management routes
library := protected.Group("/libraries")
@@ -238,6 +244,18 @@ func main() {
conflicts.DELETE("/:id", conflictHandler.DeleteConflict)
conflicts.POST("/dismiss-all", conflictHandler.DismissAllResolved)
// Sync queue management routes (protected - require user auth)
queue := protected.Group("/queue")
queue.GET("/devices/:device_id/stats", queueHandler.GetDeviceQueueStats)
queue.GET("/devices/:device_id/items", queueHandler.ListDeviceQueueItems)
queue.POST("/items/:item_id/retry", queueHandler.RetryQueueItem)
queue.DELETE("/items/:item_id", queueHandler.DeleteQueueItem)
queue.DELETE("/devices/:device_id/clear", queueHandler.ClearDeviceQueue)
// Admin-only queue routes
adminQueue := queue.Group("", handlers.AdminMiddleware)
adminQueue.GET("/items", queueHandler.ListAllQueueItems)
// WebSocket endpoint for real-time sync
e.GET("/ws/sync", wsHandler.HandleWebSocket)