Spaces:
Sleeping
Sleeping
| """Lazy-initialised Supabase client (uses service-role key → bypasses RLS).""" | |
| from __future__ import annotations | |
| from supabase import create_client, Client | |
| from config import SUPABASE_URL, SUPABASE_SERVICE_KEY | |
| _client: Client | None = None | |
| def get_supabase() -> Client: | |
| global _client | |
| if _client is None: | |
| if not SUPABASE_URL or not SUPABASE_SERVICE_KEY: | |
| raise RuntimeError( | |
| "SUPABASE_URL and SUPABASE_SERVICE_KEY must be set in .env " | |
| "→ see .env.example" | |
| ) | |
| _client = create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY) | |
| return _client | |