Validates all required env vars at runtime with zod schemas. Skips validation during build via SKIP_ENV_VALIDATION flag. Replaces scattered process.env access with typed env imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
20 lines
533 B
TypeScript
20 lines
533 B
TypeScript
import { createClient } from '@supabase/supabase-js'
|
|
import type { SupabaseDatabase } from '@pascal-app/db'
|
|
import { env } from '@/env.mjs'
|
|
|
|
/**
|
|
* Supabase client for server-side use with service role key
|
|
* Bypasses Row Level Security (RLS) - use with caution
|
|
* Always filter by user_id to enforce permissions
|
|
*/
|
|
export const supabaseAdmin = createClient<SupabaseDatabase>(
|
|
env.NEXT_PUBLIC_SUPABASE_URL,
|
|
env.SUPABASE_SERVICE_ROLE_KEY,
|
|
{
|
|
auth: {
|
|
persistSession: false,
|
|
autoRefreshToken: false,
|
|
},
|
|
},
|
|
)
|