0
0
Supabasecloud~20 mins

Creating Edge Functions with Deno in Supabase - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Supabase Edge Function Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What is the output of this Deno Edge Function?

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?

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 });
}
AHello, Alice!
BHello, Guest!
CError: name parameter missing
DHello, undefined!
Attempts:
2 left
💡 Hint

Check how the function reads query parameters from the URL.

Configuration
intermediate
2:00remaining
Which option correctly configures environment variables for a Supabase Edge Function using Deno?

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?

AUse a global JavaScript variable declared outside the function to store the database URL.
BPass the database URL as a query parameter in the request URL and read it inside the function.
CSet <code>DATABASE_URL</code> in the Supabase project settings under 'Environment Variables' and access it in code via <code>Deno.env.get('DATABASE_URL')</code>.
DHardcode the database URL string directly inside the Edge Function code.
Attempts:
2 left
💡 Hint

Think about secure ways to handle secrets in cloud functions.

Architecture
advanced
2:00remaining
Which architecture best describes how Supabase Edge Functions with Deno handle incoming HTTP requests?

Supabase Edge Functions run on Deno and respond to HTTP requests. Which description best fits their architecture?

AEach HTTP request triggers a new isolated Deno runtime instance that runs the function and then shuts down immediately after responding.
BA single long-running Deno process handles all requests sequentially without isolation between them.
CRequests are queued and processed in batches by a shared Deno runtime to optimize resource usage.
DThe Edge Function runs on a dedicated virtual machine that stays active 24/7 regardless of traffic.
Attempts:
2 left
💡 Hint

Think about how serverless functions typically run to scale efficiently.

security
advanced
2:00remaining
What is the safest way to restrict access to a Supabase Edge Function?

You want only authenticated users to call your Edge Function. Which method provides the best security?

ARequire users to send their username and password as query parameters to the function.
BCheck the Supabase JWT token in the request headers inside the Edge Function and verify it before processing.
CAllow all requests but log the IP addresses for manual review later.
DUse a public API key hardcoded in the function code to allow access.
Attempts:
2 left
💡 Hint

Think about how authentication tokens work in modern web apps.

Best Practice
expert
2:00remaining
Which practice optimizes cold start performance for Supabase Edge Functions written in Deno?

Cold starts can slow down your Edge Functions. Which approach best reduces cold start latency?

AUse global variables to store user data between requests.
BInclude large libraries and modules to handle all possible use cases in one function.
CWrite synchronous blocking code to ensure sequential execution.
DMinimize external dependencies and keep the function code small and focused.
Attempts:
2 left
💡 Hint

Think about what affects startup time in serverless functions.