Add library-based scanning and media item endpoints
- Add POST /api/libraries/:id/scan endpoint for admin library scanning - Add GET /api/libraries/:id/media-items endpoint for library media items - Move /api/libraries/types to public endpoint (no auth required) - Update ScanEbooks handler to support library_id parameter
This commit is contained in:
+20
-4
@@ -115,6 +115,13 @@ func main() {
|
||||
|
||||
// Protected routes
|
||||
protected := e.Group("/api", jwtMiddleware)
|
||||
|
||||
// Setup ebook handler routes first (so we can use it for library scan)
|
||||
h := handlers.SetupRoutes(protected, queries)
|
||||
|
||||
// Public library types endpoint (no authentication required)
|
||||
e.GET("/api/libraries/types", libraryHandler.GetLibraryTypes)
|
||||
|
||||
protected.GET("/auth/profile", authHandler.GetProfile)
|
||||
protected.PUT("/auth/profile", authHandler.UpdateProfile)
|
||||
protected.POST("/auth/refresh", authHandler.RefreshAccessToken)
|
||||
@@ -126,7 +133,6 @@ func main() {
|
||||
|
||||
// Library management routes
|
||||
library := protected.Group("/libraries")
|
||||
library.GET("/types", libraryHandler.GetLibraryTypes)
|
||||
|
||||
// Admin-only library routes
|
||||
adminLibrary := library.Group("", handlers.AdminMiddleware)
|
||||
@@ -139,6 +145,19 @@ func main() {
|
||||
adminLibrary.GET("/:id/folders", libraryHandler.GetLibraryFolders)
|
||||
adminLibrary.DELETE("/:id/folders", libraryHandler.DeleteLibraryFolder)
|
||||
adminLibrary.GET("/:id/stats", libraryHandler.GetLibraryStats)
|
||||
adminLibrary.POST("/:id/scan", func(c echo.Context) error {
|
||||
libraryID := c.Param("id")
|
||||
scanReq := map[string]interface{}{
|
||||
"library_id": libraryID,
|
||||
}
|
||||
c.Set("scan_request", scanReq)
|
||||
return h.ScanEbooks(c)
|
||||
})
|
||||
adminLibrary.GET("/:id/media-items", func(c echo.Context) error {
|
||||
libraryID := c.Param("id")
|
||||
c.QueryParams().Set("library_id", libraryID)
|
||||
return h.ListMediaItems(c)
|
||||
})
|
||||
|
||||
// User library visibility control
|
||||
protected.POST("/libraries/visibility", libraryHandler.SetLibraryVisibility)
|
||||
@@ -173,9 +192,6 @@ func main() {
|
||||
// Static files
|
||||
e.Static("/static", "web/static")
|
||||
|
||||
// Routes
|
||||
h := handlers.SetupRoutes(protected, queries)
|
||||
|
||||
// Start scheduler for auto-scanning
|
||||
go h.StartScheduler()
|
||||
defer h.StopScheduler()
|
||||
|
||||
Reference in New Issue
Block a user