feat(backend): add server-side directory browsing API

- Add BrowseDirectories() to library service with path traversal protection
- Add BrowseDirectories handler with proper error handling
- Register GET /api/libraries/browse endpoint (admin-only)
- Returns current path, parent path, and list of subdirectories
- Security: blocks "..", validates path exists, checks is directory

Fixes: Issue 2 (backend)
This commit is contained in:
2026-02-23 17:02:52 -05:00
parent c333c82c6b
commit 2af035d87f
3 changed files with 67 additions and 0 deletions
+1
View File
@@ -28,6 +28,7 @@ func registerLibraryRoutes(cfg *Config) {
adminLibrary := library.Group("", handlers.AdminMiddleware)
adminLibrary.POST("", cfg.LibraryHandler.CreateLibrary)
adminLibrary.GET("", cfg.LibraryHandler.ListLibraries)
adminLibrary.GET("/browse", cfg.LibraryHandler.BrowseDirectories)
adminLibrary.GET("/:id", cfg.LibraryHandler.GetLibrary)
adminLibrary.PUT("/:id", cfg.LibraryHandler.UpdateLibrary)
adminLibrary.DELETE("/:id", cfg.LibraryHandler.DeleteLibrary)