Files
supabase/examples/ai/edge-functions/supabase/migrations/20240410041607_database-webhook.sql
VaibhavandTomas Pozo d5fde192d5 examples: migrate Edge Functions to @supabase/server (#46890)
- extends/supersedes: #46665 
- towards COM-269

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Standardized Edge Function entrypoints across examples to a consistent
`export default` shape, with runtime-provided admin access for
storage/database operations.
  * Updated public endpoint handling to use appropriate auth modes.
* **Bug Fixes**
* Improved error handling to return structured JSON responses with
correct HTTP status codes for invalid requests and failures.
  * Harmonized local invocation examples to use the right header format.
* **Chores**
* Updated example `verify_jwt` settings to disable JWT verification for
public/demo endpoints.
* **Documentation**
  * Fixed README typo and refreshed invocation curl examples.
* **Tests**
  * None.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Tomas Pozo <tomaspozogarzon@gmail.com>
2026-06-26 15:04:46 -05:00

31 lines
1.2 KiB
SQL

-- Insert your <PROJECT-REF> and <SUPABASE_SECRET_KEY> below, then uncomment the trigger creation and run `supabase db push`
-- Alternatively, head to the Database Webhook settings https://supabase.com/dashboard/project/_/database/hooks
-- Select "Create a new Hook" > Table "public.embeddings" > check "INSERT" & "Update" > Supabase Edge Functions > Add apiKey header with secret key
-- CREATE TRIGGER "on_inserted_or_updated_embedding"
-- AFTER INSERT
-- OR
-- UPDATE OF content ON public.embeddings FOR EACH ROW
-- EXECUTE FUNCTION supabase_functions.http_request (
-- 'https://<PROJECT-REF>.supabase.co/functions/v1/generate-embedding',
-- 'POST',
-- '{"Content-type":"application/json","apikey":"<SUPABASE_SECRET_KEY>"}',
-- '{}',
-- '5000'
-- );
-- ------------------------
-- FOR LOCAL TESTING ONLY. REMOVE OR COMMENT OUT WHEN PUSHING TO HOSTED PROJECT!
-- CREATE TRIGGER "on_inserted_or_updated_embedding"
-- AFTER INSERT
-- OR
-- UPDATE OF content ON public.embeddings FOR EACH ROW
-- EXECUTE FUNCTION supabase_functions.http_request (
-- 'http://kong:8000/functions/v1/generate-embedding',
-- 'POST',
-- '{"Content-type":"application/json","apikey":"<SUPABASE_SECRET_KEY>"}',
-- '{}',
-- '5000'
-- );