refactor(router): organize scanner routes into dedicated file

Phase 4 of code organization plan

Changes:
- Create internal/router/scanner.go with registerScannerRoutes()
- Move scanner route registration from handlers to router package
- Update internal/router/router.go to call registerScannerRoutes
- Remove inline scanner routes from internal/handlers/ebook.go

Scanner routes now centralized in router/scanner.go:
- POST /scanner/scan - Scan ebooks
- POST /scanner/start - Start scanner
- POST /scanner/stop - Stop scanner
- GET /scanner/status/:jobId - Get scan status
- POST /scanner/watch/start - Start watch mode
- POST /scanner/watch/stop - Stop watch mode
- GET /scanner/watch/status - Get watch mode status

This improves code organization by separating route registration
from handler logic, making the codebase easier to maintain and
follows the established pattern of organizing routes by feature.
This commit is contained in:
2026-02-07 17:08:00 -05:00
parent 9238fad8d5
commit 46a03ebfda
2 changed files with 21 additions and 10 deletions
+1 -10
View File
@@ -142,16 +142,7 @@ func SetupRoutes(g *echo.Group, db *database.Queries, connManager *wsync.Connect
admin.PUT("/media-items/:id", h.UpdateMediaItem)
admin.DELETE("/media-items/:id", h.DeleteMediaItem)
// Scanner routes (admin only)
admin.POST("/scanner/scan", h.ScanEbooks)
admin.POST("/scanner/start", h.StartScanner)
admin.POST("/scanner/stop", h.StopScanner)
admin.GET("/scanner/status/:jobId", h.GetScanStatus)
// Watch mode routes (admin only)
admin.POST("/scanner/watch/start", h.StartWatchMode)
admin.POST("/scanner/watch/stop", h.StopWatchMode)
admin.GET("/scanner/watch/status", h.GetWatchModeStatus)
// Scanner routes are registered in router/scanner.go
return h
}