Files
bookhoard/internal/router/collections.go
T
john-okeefe 296c45e870 refactor(router): Phase 5 - update router package with new handlers
- Update Config struct to replace EbookHandler with MediaHandler, SearchHandler, MatchingHandler
- Add CollectionHandler to Config struct
- Update RegisterRoutes to call new registration functions
- Create registerCollectionsRoutes for 15 collection endpoints
- Create registerSearchRoutes for search endpoints (uses MediaHandler.SearchMediaItems, MatchingHandler.QueryBooks)
- Create registerMatchingRoutes for 8 matching/linking endpoints
- Update registerMediaRoutes to use cfg.MediaHandler (adds 24 media endpoints)
- Create registerProgressRoutes for 3 universal progress endpoints

All 57 routes preserved and properly registered with correct handlers.
No functionality lost, all endpoints work identically.

This is Phase 5 of the ebook.go refactoring plan.
2026-02-07 19:50:19 -05:00

31 lines
1.4 KiB
Go

package router
func registerCollectionsRoutes(cfg *Config) {
e := cfg.Echo
// JWT middleware for protected routes
jwtMiddleware := createJWTMiddleware(cfg)
protected := e.Group("/api", jwtMiddleware)
// Collections API routes
collections := protected.Group("/collections")
collections.GET("", cfg.CollectionHandler.GetCollections)
collections.POST("", cfg.CollectionHandler.CreateCollection)
collections.GET("/:id", cfg.CollectionHandler.GetCollection)
collections.PUT("/:id", cfg.CollectionHandler.UpdateCollection)
collections.DELETE("/:id", cfg.CollectionHandler.DeleteCollection)
collections.GET("/:id/books", cfg.CollectionHandler.GetBookCollections)
collections.POST("/:id/books", cfg.CollectionHandler.AddBooks)
collections.DELETE("/:id/books/:bookId", cfg.CollectionHandler.RemoveBook)
collections.POST("/:id/books/bulk-remove", cfg.CollectionHandler.BulkRemoveBooks)
collections.POST("/bulk-add-books", cfg.CollectionHandler.HandleBulkAddBooks)
collections.POST("/test-rules", cfg.CollectionHandler.TestRules)
// Device shelf mapping routes
deviceCollections := protected.Group("/devices/:id/collections")
deviceCollections.GET("", cfg.CollectionHandler.GetDeviceMappings)
deviceCollections.POST("", cfg.CollectionHandler.CreateDeviceMapping)
deviceCollections.PUT("/:collectionId", cfg.CollectionHandler.UpdateDeviceMapping)
deviceCollections.DELETE("/:collectionId", cfg.CollectionHandler.DeleteDeviceMapping)
}