Whizan Cloud ServicesDocumentation Hub
Documentation/Compute & Applications/Serverless Edge Functions

Serverless Edge Functions

Supported:TypeScriptJavaScript (ES Modules)Web Standards API (Request / Response)

When to Use This Service

Ideal Use Cases
  • Third-party webhook handlers (Stripe payments, GitHub events, Shopify webhooks, Slack interactions)
  • Authentication hooks, token validation, and custom header transformations
  • Lightweight database mutations, user signups, and email notifications
  • Micro-endpoints and utility APIs where keeping a 24/7 server running is inefficient
  • Event-driven compute dispatched on demand with zero baseline memory overhead
When to Choose Another Workload
  • Heavy compute jobs running longer than 30 seconds
  • Applications requiring native filesystem persistence or background daemon threads
  • Full web frameworks requiring extensive server middleware

How to Use & Deploy

Option 1Deploy via Web Console

  1. 1In the console, click 'Create Edge Function' or navigate to Edge Functions.
  2. 2Enter a unique service name and choose your runtime (TypeScript / JavaScript).
  3. 3Write or paste your function handler in the interactive editor or deploy from your local workspace.
  4. 4Configure endpoint security: toggle 'Public Webhook' for third-party hooks, or keep 'Protected' to enforce API Key verification.
  5. 5Click 'Deploy Function'. Your endpoint is immediately accessible worldwide.

Option 2Deploy via CLI & Terminal

Deploy instantly from your local workspace terminal using the global Whizan CLI:

$ whizan function deploy --name payments-webhook
Or prompt your AI Coding Assistant (Cursor / Antigravity MCP):
“Create and deploy a serverless edge function for Stripe webhook handling”

Practical Project Example

handler.ts
// Standard Web Request/Response handler
export default async function handler(request: Request): Promise<Response> {
  if (request.method === "GET") {
    return Response.json({ status: "active", time: new Date().toISOString() });
  }

  if (request.method === "POST") {
    const payload = await request.json().catch(() => ({}));
    
    // Process webhook event
    console.log("Received event:", payload.event);

    return Response.json({ success: true, processedAt: Date.now() }, { status: 200 });
  }

  return new Response("Method Not Allowed", { status: 405 });
}

Configuration Reference

Parameter / SettingDescriptionDefault / Recommended
isPublicWhether the endpoint can be invoked without an API key (ideal for Stripe/GitHub webhooks)false (Protected)
RuntimeLanguage runtime environmentTYPESCRIPT_V8
API KeyFunction-specific authorization key (whz_fn_live_...) required when isPublic is falseAuto-generated
Route PathSubpath for this function endpoint (e.g. /webhook, /subscribe)/*

Best Practices & Pro Tips

Tip 1Use 'isPublic: true' strictly for third-party webhook receivers that cannot send custom authorization headers.
Tip 2Use 'isPublic: false' with dedicated Function API keys for user data, database mutations, and internal business logic.
Tip 3Edge functions use the standard Web fetch API and Response object — no proprietary vendor wrapper required.