github.com/supabase/cli@v1.168.1/internal/functions/new/templates/index.ts (about)

     1  // Follow this setup guide to integrate the Deno language server with your editor:
     2  // https://deno.land/manual/getting_started/setup_your_environment
     3  // This enables autocomplete, go to definition, etc.
     4  
     5  // Setup type definitions for built-in Supabase Runtime APIs
     6  /// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
     7  
     8  console.log("Hello from Functions!")
     9  
    10  Deno.serve(async (req) => {
    11    const { name } = await req.json()
    12    const data = {
    13      message: `Hello ${name}!`,
    14    }
    15  
    16    return new Response(
    17      JSON.stringify(data),
    18      { headers: { "Content-Type": "application/json" } },
    19    )
    20  })
    21  
    22  /* To invoke locally:
    23  
    24    1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start)
    25    2. Make an HTTP request:
    26  
    27    curl -i --location --request POST 'http://127.0.0.1:{{ .Port }}/functions/v1/{{ .Slug }}' \
    28      --header 'Authorization: Bearer {{ .Token }}' \
    29      --header 'Content-Type: application/json' \
    30      --data '{"name":"Functions"}'
    31  
    32  */