feat: configura cliente supabase com variaveis de ambiente
This commit is contained in:
parent
fbe6a01bc8
commit
3cabbbab4f
8
.env.local.example
Normal file
8
.env.local.example
Normal file
@ -0,0 +1,8 @@
|
||||
# Supabase — projeto InAudit Hotel
|
||||
VITE_SUPABASE_URL=https://acdvblhzzaneddlxqyst.supabase.co
|
||||
VITE_SUPABASE_ANON_KEY=
|
||||
VITE_SUPABASE_SCHEMA=reserva_hotel
|
||||
|
||||
# Chatwoot — token de integração (Fase 2)
|
||||
VITE_CHATWOOT_API_URL=https://chatwoot.fazer.ai
|
||||
VITE_CHATWOOT_API_TOKEN=
|
||||
16
src/lib/supabase.ts
Normal file
16
src/lib/supabase.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import type { Database } from '@/types/database'
|
||||
|
||||
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
|
||||
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY
|
||||
const supabaseSchema = import.meta.env.VITE_SUPABASE_SCHEMA ?? 'reserva_hotel'
|
||||
|
||||
if (!supabaseUrl || !supabaseAnonKey) {
|
||||
throw new Error(
|
||||
'Variáveis VITE_SUPABASE_URL e VITE_SUPABASE_ANON_KEY não estão definidas. Copie .env.local.example para .env.local e preencha.'
|
||||
)
|
||||
}
|
||||
|
||||
export const supabase = createClient<Database>(supabaseUrl, supabaseAnonKey, {
|
||||
db: { schema: supabaseSchema as 'reserva_hotel' },
|
||||
})
|
||||
6
src/lib/utils.ts
Normal file
6
src/lib/utils.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { clsx, type ClassValue } from 'clsx'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
15
src/types/database.ts
Normal file
15
src/types/database.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// Este arquivo é gerado automaticamente via `pnpm supabase:types`.
|
||||
// Não edite à mão. Regenerar após cada migration.
|
||||
// Placeholder inicial — Task 6 substitui com tipos reais.
|
||||
|
||||
export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[]
|
||||
|
||||
export type Database = {
|
||||
reserva_hotel: {
|
||||
Tables: Record<string, never>
|
||||
Views: Record<string, never>
|
||||
Functions: Record<string, never>
|
||||
Enums: Record<string, never>
|
||||
CompositeTypes: Record<string, never>
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
"types": ["vitest/globals", "@testing-library/jest-dom"]
|
||||
"types": ["vite/client", "vitest/globals", "@testing-library/jest-dom"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user