From 7c4a37175b855a8031e1d9234bd641efe0dd2860 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 2 Feb 2026 16:46:22 -0500 Subject: [PATCH] feat: add SSR data helpers to library handler - Add GetUserVisibleLibrariesData() method for server-side rendering - Add GetLibraryTypeData() method for SSR type fetching - These helpers return data directly instead of JSON responses - Enables Hybrid SSR pattern while preserving API endpoints - Add context import for new methods --- internal/handlers/library.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/handlers/library.go b/internal/handlers/library.go index d8d0822..3d19bdb 100644 --- a/internal/handlers/library.go +++ b/internal/handlers/library.go @@ -3,6 +3,7 @@ package handlers import ( "bookhoard/internal/database" "bookhoard/internal/services" + "context" "net/http" "os" "path/filepath" @@ -302,3 +303,13 @@ func parseUUID(uuidStr string) (pgtype.UUID, error) { } return pgtype.UUID{Bytes: [16]byte(parsedUUID), Valid: true}, nil } + +// GetUserVisibleLibrariesData returns libraries for SSR (not JSON response) +func (h *LibraryHandler) GetUserVisibleLibrariesData(ctx context.Context, userID pgtype.UUID) ([]database.GetUserVisibleLibrariesRow, error) { + return h.libraryService.GetUserVisibleLibraries(ctx, userID) +} + +// GetLibraryTypeData returns all library types for SSR (not JSON response) +func (h *LibraryHandler) GetLibraryTypeData(ctx context.Context) ([]database.LibraryTypes, error) { + return h.libraryService.GetLibraryTypes(ctx) +}