feat(dashboard): implement Phase 7 router registration and config setup
Add DashboardService and DashboardHandler to application configuration: Router Config Updates (internal/router/router.go): - Add services import for DashboardService type - Add DashboardService field to Config struct - DashboardService: Used by SSR routes in frontend.go for data fetching - DashboardHandler: Used by API routes in dashboard.go for JSON endpoints Server Initialization (cmd/server/main.go): - Create dashboardService instance using services.NewDashboardService(queries) - Keep dashboardHandler creation (already exists from Phase 4) - Add DashboardService to routerConfig - Both services now available for dependency injection Test Helpers (cmd/server/tests/test_helpers.go): - Create dashboardService instance for testing - Create dashboardHandler instance for testing - Add both DashboardService and DashboardHandler to routerConfig - Ensures test environment matches production setup Architecture Rationale: - DashboardService: Service layer with business logic (reusable by SSR, mobile) - DashboardHandler: HTTP handler layer (JSON API endpoints) - Separation allows SSR templates to call service directly - API routes use handler for proper HTTP response handling - Mobile apps can use API endpoints via DashboardHandler All three files updated consistently for complete integration.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"bookhoard/internal/handlers"
|
||||
"bookhoard/internal/middleware"
|
||||
ratelimit "bookhoard/internal/middleware"
|
||||
"bookhoard/internal/services"
|
||||
"bookhoard/internal/sync"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -48,6 +49,7 @@ type Config struct {
|
||||
QueueHandler *handlers.QueueHandler
|
||||
CollectionHandler *handlers.CollectionHandler
|
||||
DashboardHandler *handlers.DashboardHandler
|
||||
DashboardService *services.DashboardService
|
||||
OPDSHandler *handlers.OPDSHandler
|
||||
SystemSettingsHandler *handlers.SystemSettingsHandler
|
||||
ConnManager *sync.ConnectionManager
|
||||
|
||||
Reference in New Issue
Block a user