From 91288a0695ad7cdb7b4d97f196ee57bfd25666a3 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 19 Feb 2026 20:59:24 -0500 Subject: [PATCH] feat(dashboard): register dashboard API routes Add dashboard route registration and wire up handler: Router Changes: - Add DashboardHandler to router.Config struct - Create internal/router/dashboard.go with dashboard route registration - Register dashboard routes in main RegisterRoutes function Dashboard Routes (all protected by JWT): - GET /api/dashboard/sections: Get dashboard sections for user * Query params: library_id (required), limit (optional, default 20, max 100) * Returns: JSON with sections array - PUT /api/dashboard/preferences: Update dashboard preferences * Body: library_id, hidden_collections, collection_order, items_per_section * Returns: Updated preferences - POST /api/dashboard/restore-system-collection: Restore system collection to defaults * Body: collection_name (must be valid system collection) * Returns: Success message Server Integration: - Create dashboardHandler in cmd/server/main.go - Add dashboardHandler to routerConfig - Routes are automatically registered on server startup --- internal/router/dashboard.go | 13 +++++++++++++ internal/router/router.go | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 internal/router/dashboard.go diff --git a/internal/router/dashboard.go b/internal/router/dashboard.go new file mode 100644 index 0000000..6b3da91 --- /dev/null +++ b/internal/router/dashboard.go @@ -0,0 +1,13 @@ +package router + +func registerDashboardRoutes(cfg *Config) { + e := cfg.Echo + + jwtMiddleware := createJWTMiddleware(cfg) + protected := e.Group("/api", jwtMiddleware) + + dashboard := protected.Group("/dashboard") + dashboard.GET("/sections", cfg.DashboardHandler.GetSections) + dashboard.PUT("/preferences", cfg.DashboardHandler.UpdatePreferences) + dashboard.POST("/restore-system-collection", cfg.DashboardHandler.RestoreSystemCollection) +} diff --git a/internal/router/router.go b/internal/router/router.go index 8bb5bd4..fedbe01 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -47,6 +47,7 @@ type Config struct { AnalyticsHandler *handlers.AnalyticsHandler QueueHandler *handlers.QueueHandler CollectionHandler *handlers.CollectionHandler + DashboardHandler *handlers.DashboardHandler OPDSHandler *handlers.OPDSHandler SystemSettingsHandler *handlers.SystemSettingsHandler ConnManager *sync.ConnectionManager @@ -164,6 +165,7 @@ func RegisterRoutes(cfg *Config) *handlers.Handler { registerDeviceRoutes(cfg) registerSyncRoutes(cfg) registerCollectionsRoutes(cfg) + registerDashboardRoutes(cfg) registerMediaRoutes(cfg) registerSearchRoutes(cfg) registerMatchingRoutes(cfg)