Initial commit: Vuelato - buscador de vuelos
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Nuxt 4 + Supabase + Flightics API. Incluye búsqueda de vuelos, inspiraciones, watchlist, tracking de precios y mapa interactivo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
server/utils/supabase-admin.ts
Normal file
25
server/utils/supabase-admin.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import type { SupabaseClient } from '@supabase/supabase-js'
|
||||
|
||||
let _client: SupabaseClient | null = null
|
||||
|
||||
/**
|
||||
* Cliente Supabase con service_role para uso fuera de event handlers (ej: worker plugin).
|
||||
* Bypasses RLS — usar solo en contextos server-side confiables.
|
||||
*/
|
||||
export function getSupabaseAdmin(): SupabaseClient {
|
||||
if (_client) return _client
|
||||
|
||||
const url = process.env.SUPABASE_URL
|
||||
const key = process.env.SUPABASE_SERVICE_ROLE_KEY
|
||||
|
||||
if (!url || !key) {
|
||||
throw new Error('SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY not configured')
|
||||
}
|
||||
|
||||
_client = createClient(url, key, {
|
||||
auth: { autoRefreshToken: false, persistSession: false }
|
||||
})
|
||||
|
||||
return _client
|
||||
}
|
||||
Reference in New Issue
Block a user