Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

init a mailgun edge function

Jean-Baptiste Kaiser591d95b8bb65
diff --git a/makefile b/makefile
index 632ba567..329916d7 100644
--- a/makefile
+++ b/makefile
@@ -9,10 +9,13 @@ install: package.json ## install dependencies
start-supabase: ## start supabase locally
npx supabase start
+start-supabase-functions: ## start the supabase Functions watcher
+ npx supabase functions serve
+
start-app: ## start the app locally
npm run dev
-start: start-supabase start-app## start the stack locally
+start: start-supabase start-supabase-functions start-app ## start the stack locally
stop-supabase: ## stop local supabase
npx supabase stop
diff --git a/supabase/config.toml b/supabase/config.toml
index 4e1e101d..ca00d512 100644
--- a/supabase/config.toml
+++ b/supabase/config.toml
@@ -149,3 +149,6 @@ s3_region = "env(S3_REGION)"
s3_access_key = "env(S3_ACCESS_KEY)"
# Configures AWS_SECRET_ACCESS_KEY for S3 bucket
s3_secret_key = "env(S3_SECRET_KEY)"
+
+[functions.mailgun]
+verify_jwt = false
\ No newline at end of file
diff --git a/supabase/functions/mailgun/index.ts b/supabase/functions/mailgun/index.ts
new file mode 100644
index 00000000..1ef3fa63
--- /dev/null
+++ b/supabase/functions/mailgun/index.ts
@@ -0,0 +1,30 @@
+// Follow this setup guide to integrate the Deno language server with your editor:
+// https://deno.land/manual/getting_started/setup_your_environment
+// This enables autocomplete, go to definition, etc.
+
+// Setup type definitions for built-in Supabase Runtime APIs
+import 'jsr:@supabase/functions-js/edge-runtime.d.ts';
+
+console.log('Hello from Functions!');
+
+Deno.serve(async req => {
+ const { name } = await req.json();
+ const data = {
+ message: `Hello ${name}!`,
+ };
+
+ return new Response(JSON.stringify(data), {
+ headers: { 'Content-Type': 'application/json' },
+ });
+});
+
+/* To invoke locally:
+
+ 1. Run `supabase start` (see: https://supabase.com/docs/reference/cli/supabase-start)
+ 2. Make an HTTP request:
+
+ curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/mailgun' \
+ --header 'Content-Type: application/json' \
+ --data '{"name":"Functions"}'
+
+*/