Supabase Edge Function Generator
backend
TypeScript
scaffolding
zen
Create a Supabase Edge Function with Deno runtime for specific backend logic requirements.
By alex_dev
12/8/2025
Prompt
Create a Supabase Edge Function with the following specifications:
Function Details
- Function Name: [e.g., send-email, process-payment, generate-report]
- Purpose: [What does this function do?]
- HTTP Methods: [GET, POST, PUT, DELETE]
- Authentication Required: [Yes / No]
Input Parameters
Define the expected request body/query parameters:
{
[field1]: [type and description],
[field2]: [type and description],
[field3]: [type and description]
}
Functionality Requirements
Database Operations (if applicable)
- Tables to Query: [table1, table2]
- Operations: [SELECT / INSERT / UPDATE / DELETE]
- Filters/Conditions: [Specify any where clauses or joins]
External API Calls (if applicable)
- Service: [e.g., SendGrid, Stripe, OpenAI]
- Endpoint: [API endpoint to call]
- Required Environment Variables: [API_KEY, SECRET, etc.]
Business Logic
[Describe the core logic this function should implement]
- Step 1: [e.g., Validate input data]
- Step 2: [e.g., Query user from database]
- Step 3: [e.g., Call external API]
- Step 4: [e.g., Update database with result]
- Step 5: [e.g., Return formatted response]
Response Format
Define the expected response structure:
// Success response:
{
success: boolean,
data: { ... },
message?: string
}
// Error response:
{
success: false,
error: string,
code?: string
}
Additional Requirements
CORS Configuration
- Allowed Origins: [* / specific domains]
- Allowed Headers: [authorization, content-type, etc.]
- Allowed Methods: [GET, POST, etc.]
Error Handling
- Handle invalid input with 400 status
- Handle unauthorized access with 401 status
- Handle database errors gracefully
- Return descriptive error messages
Security
- Validate JWT token if authentication required
- Sanitize input data
- Check user permissions if needed
- Rate limiting considerations
Environment Variables Required
List all environment variables needed:
SUPABASE_URLSUPABASE_ANON_KEY[CUSTOM_API_KEY][OTHER_ENV_VARS]
Code Requirements
- Use Deno runtime with TypeScript
- Import from
https://deno.land/std@0.168.0/http/server.ts - Use
@supabase/supabase-js@2for database operations - Include proper TypeScript types
- Add error handling with try-catch
- Return proper HTTP status codes
- Include CORS headers if needed
Generate the complete Edge Function code in /supabase/functions/[function-name]/index.ts format, ready to deploy with supabase functions deploy.
Tags
supabase
edge-functions
deno
serverless
Tested Models
gpt-4
claude-3-5-sonnet