Edge Functions 생성
# 함수 생성
supabase functions new hello-world
# functions/hello-world/index.ts
import { serve } from "https://deno.land/std/http/server.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js";
serve(async (req) => {
const supabase = createClient(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!
);
const { data } = await supabase.from("posts").select("*");
return new Response(JSON.stringify(data), {
headers: { "Content-Type": "application/json" },
});
});
배포
supabase functions deploy hello-world
댓글 0