mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-17 05:47:52 +00:00
This commit is contained in:
parent
4765be66da
commit
de28dea3b5
22
netlify.toml
Normal file
22
netlify.toml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[build]
|
||||||
|
command = "npm run build"
|
||||||
|
publish = "dist"
|
||||||
|
|
||||||
|
[build.environment]
|
||||||
|
NODE_VERSION = "18"
|
||||||
|
VITE_SUPABASE_URL = "https://bsjlbnyslxzsdwxvkaap.supabase.co"
|
||||||
|
VITE_RESEND_API_KEY = "GEoM_cVt4qyBFVkngJWi8wBrMWOiPMUAuxuFGykcP0A"
|
||||||
|
VITE_APP_URL = "https://historiasmagicas.netlify.app/"
|
||||||
|
|
||||||
|
[[redirects]]
|
||||||
|
from = "/*"
|
||||||
|
to = "/index.html"
|
||||||
|
status = 200
|
||||||
|
|
||||||
|
[dev]
|
||||||
|
command = "npm run dev"
|
||||||
|
port = 5173
|
||||||
|
publish = "dist"
|
||||||
|
|
||||||
|
[functions]
|
||||||
|
node_bundler = "esbuild"
|
||||||
49
supabase/migrations/XXX_create_audio_processing_trigger.sql
Normal file
49
supabase/migrations/XXX_create_audio_processing_trigger.sql
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
-- Criar a trigger function
|
||||||
|
create function handle_new_recording()
|
||||||
|
returns trigger
|
||||||
|
language plpgsql
|
||||||
|
security definer
|
||||||
|
as $$
|
||||||
|
declare
|
||||||
|
response json;
|
||||||
|
begin
|
||||||
|
-- Apenas processa registros com status pending_analysis
|
||||||
|
if NEW.status = 'pending_analysis' then
|
||||||
|
-- Chama a Edge Function
|
||||||
|
select
|
||||||
|
content into response
|
||||||
|
from
|
||||||
|
http((
|
||||||
|
'POST',
|
||||||
|
current_setting('app.settings.edge_function_url') || '/process-audio',
|
||||||
|
ARRAY[
|
||||||
|
('Authorization', 'Bearer ' || current_setting('app.settings.service_role_key'))::http_header,
|
||||||
|
('Content-Type', 'application/json')::http_header
|
||||||
|
],
|
||||||
|
'application/json',
|
||||||
|
json_build_object(
|
||||||
|
'record', json_build_object(
|
||||||
|
'id', NEW.id,
|
||||||
|
'story_id', NEW.story_id,
|
||||||
|
'student_id', NEW.student_id,
|
||||||
|
'audio_url', NEW.audio_url,
|
||||||
|
'status', NEW.status
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)::http_request);
|
||||||
|
end if;
|
||||||
|
|
||||||
|
return NEW;
|
||||||
|
end;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Configurar as variáveis de ambiente
|
||||||
|
select set_config('app.settings.edge_function_url', 'https://bsjlbnyslxzsdwxvkaap.supabase.co/functions/v1', false);
|
||||||
|
select set_config('app.settings.service_role_key', 'seu_service_role_key', false);
|
||||||
|
|
||||||
|
-- Criar a trigger
|
||||||
|
create trigger process_new_recording
|
||||||
|
after insert or update
|
||||||
|
on story_recordings
|
||||||
|
for each row
|
||||||
|
execute function handle_new_recording();
|
||||||
Loading…
Reference in New Issue
Block a user