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
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user