Backend2025년 8월 3일2분 읽기

Supabase Edge Functions — Deno 기반 서버리스

YS
YoungSam
조회 1440

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
SupabaseEdge FunctionsDeno

댓글 0

아직 댓글이 없습니다.