You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: eliminate workarounds, replace with idiomatic patterns
## hooks.server.ts
- Remove redundant getSession() call (getUser() is sufficient for JWT validation)
- Remove manual expired-session check (supabase handles this internally)
- Replace 2 separate DB queries (memberships + subscriptions) with get_user_context RPC
— consistent with layout.server.ts, saves 2 round-trips per protected request
## routes/+page.server.ts
- Replace raw memberships query with get_user_context RPC (consistent with hooks)
## admin/settings/+page.server.ts action
- Replace get_user_context RPC call (fetches too much) with targeted memberships query
for just tenant_id — right tool for the job
## format.ts
- Remove locale hack in formatCurrency (was manually mapping EUR→de-DE, USD→en-US, GBP→en-GB)
- Use undefined locale so Intl.NumberFormat picks the correct locale for the currency automatically
## supabase.ts
- Replace typeof window !== 'undefined' with browser from $app/environment (consistent with rest of codebase)
## (app)/+layout.svelte
- Change $effect → $effect.pre for session/settings init
— ensures stores are populated BEFORE first render, not after
## bookings/[type]/+page.svelte
- Remove dead client-side isValidType guard (server already throws 404 for invalid types)
- Use $derived for type/icon to properly track reactive data prop changes
- Use satisfies for icons record type safety
## SQL: search_products
- Change 'english' dictionary → 'simple' for language-agnostic full-text search
- Adds ILIKE fallback for partial/typo matching
- Fixes Greek product name search that was broken with English stemming
## SQL: mv_best_sellers
- Remove synchronous refresh trigger that was blocking every order INSERT transaction
- Convert to scheduled refresh via keep-alive cron (daily) using service_role RPC
- Add refresh_mv_best_sellers() call to keep-alive endpoint
## mocks.ts
- Add rpc() mock to createSupabaseMock (now required since hooks uses get_user_context)
- Build get_user_context response from existing config shape
- Add rpc to return type signature
## tests
- Remove session-expiry test (the feature was removed from hooks — getSession no longer called)
0 commit comments