diff --git a/supabase/volumes/functions/main/index.ts b/supabase/volumes/functions/main/index.ts new file mode 100644 index 0000000..975e8e4 --- /dev/null +++ b/supabase/volumes/functions/main/index.ts @@ -0,0 +1,46 @@ +// Main edge function entry point +import { serve } from "https://deno.land/std@0.177.0/http/server.ts" + +serve(async (req: Request) => { + const url = new URL(req.url) + const pathname = url.pathname + + // Route to different functions based on path + if (pathname === "/trigger-n8n" || pathname === "/functions/v1/trigger-n8n") { + return await handleTriggerN8n(req) + } + + if (pathname === "/n8n-callback" || pathname === "/functions/v1/n8n-callback") { + return await handleN8nCallback(req) + } + + return new Response(JSON.stringify({ + message: "Mylder Edge Functions", + available: ["/trigger-n8n", "/n8n-callback"] + }), { + headers: { "Content-Type": "application/json" }, + status: 200 + }) +}) + +async function handleTriggerN8n(req: Request): Promise { + // Will be implemented when connecting to n8n + return new Response(JSON.stringify({ + status: "placeholder", + message: "trigger-n8n function - to be implemented" + }), { + headers: { "Content-Type": "application/json" }, + status: 200 + }) +} + +async function handleN8nCallback(req: Request): Promise { + // Will be implemented when connecting to n8n + return new Response(JSON.stringify({ + status: "placeholder", + message: "n8n-callback function - to be implemented" + }), { + headers: { "Content-Type": "application/json" }, + status: 200 + }) +}