mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-17 13:57:51 +00:00
- Implementa Dockerfile com multi-stage build - Configura pipeline no Gitea Actions - Adiciona integração com Redis - Implementa healthchecks - Configura registry no Gitea minor: novas funcionalidades de infraestrutura
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { StoryPrompt } from '@/types/story-generator'
|
|
import { createClient } from '@supabase/supabase-js'
|
|
|
|
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
|
|
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY
|
|
|
|
if (!supabaseUrl || !supabaseAnonKey) {
|
|
throw new Error('Variáveis de ambiente do Supabase não configuradas')
|
|
}
|
|
|
|
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
|
|
auth: {
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: true
|
|
}
|
|
})
|
|
|
|
export const generateStoryFunction = async (prompt: StoryPrompt) => {
|
|
const { data: { session } } = await supabase.auth.getSession()
|
|
|
|
const response = await fetch(
|
|
'https://seu-project-ref.supabase.co/functions/v1/generate-story',
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${session?.access_token}`,
|
|
},
|
|
body: JSON.stringify(prompt),
|
|
}
|
|
)
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Falha ao gerar história')
|
|
}
|
|
|
|
return response.json()
|
|
}
|