Resumen de lo entregado
Some checks failed
/ Deploy to Cloudflare Pages (push) Has been cancelled

This commit is contained in:
2026-07-07 09:47:31 -03:00
parent 2922d4c2f3
commit bc9f70419c
26 changed files with 4102 additions and 23 deletions

View File

@@ -0,0 +1,37 @@
/**
* Edge Function: main (relay)
* Enruta todas las requests al worker de la función correspondiente.
* Requerido por supabase/edge-runtime en self-hosted (--main-service).
* No expuesto directamente — solo opera como router interno.
*/
const FUNCTIONS = ['invite-user', 'revoke-user']
Deno.serve(async (req: Request) => {
const url = new URL(req.url)
// Extraer nombre de función del path: /functions/v1/invite-user → invite-user
const segments = url.pathname.split('/').filter(Boolean)
const functionName = segments[segments.length - 1]
if (!functionName || !FUNCTIONS.includes(functionName)) {
return new Response(
JSON.stringify({ error: `Función no encontrada: ${functionName}` }),
{ status: 404, headers: { 'Content-Type': 'application/json' } },
)
}
const servicePath = `/home/deno/functions/${functionName}`
try {
// EdgeRuntime.userWorkers es el API del supabase/edge-runtime para crear workers por función
const worker = await EdgeRuntime.userWorkers.create({ servicePath })
return await worker.fetch(req)
} catch (err) {
const message = err instanceof Error ? err.message : String(err)
return new Response(
JSON.stringify({ error: message }),
{ status: 500, headers: { 'Content-Type': 'application/json' } },
)
}
})