From 9fd8a397b71b56221cc7211f6ca14207f88f338d Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 7 Feb 2026 19:50:29 -0500 Subject: [PATCH] refactor(main): Phase 6 - instantiate new handlers in main.go - Create worker for background tasks (3 concurrent workers) - Create CollectionHandler for collection endpoints - Create MediaHandler with worker for media CRUD operations - Create SearchHandler for query operations - Create MatchingHandler for book matching/linking operations - Update routerConfig to include new handlers instead of EbookHandler All handlers properly initialized and passed to router package. System is fully operational with new handler architecture. This is Phase 6 of the ebook.go refactoring plan. --- cmd/server/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index b2ebfa1..b6cc90c 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -94,6 +94,9 @@ func main() { queueProcessor := sync.NewSyncQueueProcessor(queries) go queueProcessor.Start(context.Background()) + // Create worker for background tasks + worker := services.NewWorker(3) + koreaderHandler := handlers.NewKOReaderHandler(queries, connManager, queueProcessor) wsHandler := handlers.NewWSHandler(queries, connManager, cfg.JWTSecret, deviceAuthMiddleware) conflictHandler := handlers.NewConflictHandler(queries, connManager) @@ -104,6 +107,12 @@ func main() { conversionService := services.NewConversionService(queries, "/var/bookhoard/cache/kepub") opdsHandler := handlers.NewOPDSHandler(queries, conversionService) + // NEW: Create refactored handlers + collectionHandler := handlers.NewCollectionHandler(queries, connManager) + mediaHandler := handlers.NewMediaHandler(queries, worker) + searchHandler := handlers.NewSearchHandler(queries) + matchingHandler := handlers.NewMatchingHandler(queries, connManager) + e := echo.New() // Set up validator @@ -142,11 +151,15 @@ func main() { AuthHandler: authHandler, LibraryHandler: libraryHandler, DeviceHandler: deviceHandler, + MediaHandler: mediaHandler, + SearchHandler: searchHandler, + MatchingHandler: matchingHandler, KOReaderHandler: koreaderHandler, WSHandler: wsHandler, ConflictHandler: conflictHandler, AnalyticsHandler: analyticsHandler, QueueHandler: queueHandler, + CollectionHandler: collectionHandler, OPDSHandler: opdsHandler, ConnManager: connManager, QueueProcessor: queueProcessor,