26 lines
666 B
TypeScript
26 lines
666 B
TypeScript
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
|
|
import { corsHeaders } from "../_shared/cors.ts";
|
|
|
|
console.log("Hello from Functions!");
|
|
|
|
Deno.serve(async (req) => {
|
|
const url = new URL(req.url);
|
|
const functionName = url.pathname.split("/").pop();
|
|
console.log(
|
|
`[${new Date().toISOString()}][${functionName}]: Request received`,
|
|
);
|
|
|
|
if (req.method === "OPTIONS") {
|
|
return new Response(null, { status: 204, headers: corsHeaders });
|
|
}
|
|
const { name } = await req.json();
|
|
const data = {
|
|
message: `Hello ${name}!`,
|
|
};
|
|
|
|
return new Response(
|
|
JSON.stringify(data),
|
|
{ headers: { "Content-Type": "application/json" } },
|
|
);
|
|
});
|