Consider this simple Deno Edge Function deployed on Supabase:
export async function handler(req: Request) {
const url = new URL(req.url);
const name = url.searchParams.get('name') || 'Guest';
return new Response(`Hello, ${name}!`, { status: 200 });
}What will be the response body if the function is called with the URL https://example.com?name=Alice?
export async function handler(req: Request) { const url = new URL(req.url); const name = url.searchParams.get('name') || 'Guest'; return new Response(`Hello, ${name}!`, { status: 200 }); }
Check how the function reads query parameters from the URL.
The function extracts the 'name' parameter from the URL query string. If it exists, it uses that value; otherwise, it defaults to 'Guest'. Since the URL has '?name=Alice', the response is 'Hello, Alice!'.
You want to securely access a database URL inside your Deno Edge Function on Supabase. Which configuration method correctly injects the environment variable DATABASE_URL?
Think about secure ways to handle secrets in cloud functions.
Supabase allows setting environment variables securely in project settings. Inside Deno Edge Functions, these can be accessed using Deno.env.get(). Hardcoding or passing secrets in URLs is insecure.
Supabase Edge Functions run on Deno and respond to HTTP requests. Which description best fits their architecture?
Think about how serverless functions typically run to scale efficiently.
Supabase Edge Functions run in isolated Deno runtimes per request to ensure security and scalability. Each request triggers a fresh instance that runs the function and then shuts down.
You want only authenticated users to call your Edge Function. Which method provides the best security?
Think about how authentication tokens work in modern web apps.
Verifying the JWT token in request headers ensures only authenticated users can access the function. Sending credentials in query parameters or hardcoding keys is insecure.
Cold starts can slow down your Edge Functions. Which approach best reduces cold start latency?
Think about what affects startup time in serverless functions.
Smaller code and fewer dependencies reduce the time needed to start the Deno runtime, improving cold start performance. Large libraries and blocking code increase latency. Global variables do not persist between invocations.