#
Edge Functions Overview
Supabase Edge Functions are server-side TypeScript functions that run on-demand. The Exit WeWeb Portal uses Edge Functions for complex operations and external integrations.
#
Base URL
https://edknwrcztqwhskjpoxta.supabase.co/functions/v1/
#
Authentication
Edge Functions require authentication:
Authorization: Bearer YOUR_ANON_KEY
Content-Type: application/json
#
Available Functions
#
Core Functions
- invite-client-admin - Send invitations to new client administrators
- invite-client-manager - Send invitations to new client managers
- request-new-inspections - Create bulk inspection requests
- import-past-inspections - Import historical inspection data
#
Fire Alert Functions
- fetch-fire-alerts - Fetch fire incidents from 1rwn.com API
- get-building-owner-actovia - Get building owner info from Actovia
- send-fire-alert-notification - Send email/SMS notifications
- process-fire-incidents - Orchestrate fire alert workflow
#
Request Format
All Edge Functions accept POST requests with JSON payloads:
POST /functions/v1/function-name
Authorization: Bearer YOUR_ANON_KEY
Content-Type: application/json
{
"param1": "value1",
"param2": "value2"
}
#
Response Format
Successful responses return JSON:
{
"success": true,
"data": {
"result": "Operation completed"
}
}
Error responses:
{
"success": false,
"error": "Error message",
"details": {}
}
#
CORS Configuration
All Edge Functions include CORS headers for browser compatibility:
import { corsHeaders } from '../_shared/cors.ts';
// In handler
return new Response(JSON.stringify(data), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200
});
#
Environment Variables
Edge Functions can access environment variables:
SUPABASE_URL- Supabase project URLSUPABASE_ANON_KEY- Anonymous keySUPABASE_SERVICE_ROLE_KEY- Service role key (admin operations)- Custom variables for integrations (Twilio, Resend, etc.)
#
Error Handling
Functions should handle errors gracefully:
try {
// Function logic
return new Response(JSON.stringify({ success: true, data }), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 200
});
} catch (error) {
return new Response(JSON.stringify({
success: false,
error: error.message
}), {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
status: 400
});
}
#
Development
#
Local Testing
supabase functions serve function-name
#
Deployment
supabase functions deploy function-name
#
Scheduled Functions
Some functions run on schedules via database triggers:
fetch-fire-alerts- Every 10 minutesprocess-fire-incidents- Every 5 minutes
These are configured in the Supabase dashboard under Database → Extensions → pg_cron.
#
Security Considerations
- Always validate input parameters
- Use RLS policies when accessing database
- Never expose service role key to clients
- Implement rate limiting for public endpoints
- Log security-relevant events
#
Monitoring
Edge Functions provide automatic logging:
- View logs in Supabase dashboard
- Filter by function name and time range
- Monitor error rates and performance