Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Supabase - New user function
Jakub Novákf798bd6189a1
diff --git a/supabase/functions/new_user/index.ts b/supabase/functions/new_user/index.tsnew file mode 100644index 000000000..ed161f631--- /dev/null+++ b/supabase/functions/new_user/index.ts@@ -0,0 +1,33 @@++import { serve } from 'https://deno.land/[email protected]/http/server.ts'++serve(async (req) => {+ /**+ * Creates a new contact in Loops.so on a new created user in users table.+ */+ const data = await req.json()++ const body = {+ email: data.record.email,+ userGroup: 'signUpUser'+ }+ console.log(`New user with email: ${body.email} created`)++ const res = await fetch(+ 'https://app.loops.so/api/v1/contacts/create',+ {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' , 'Accept': 'application/json', 'Authorization': `Bearer ${Deno.env.get('API_KEY_LOOPS')}`},+ body: JSON.stringify(body)+ }+ )+ if (res.ok) {+ console.log('Success')+ return new Response(await res.json())+ } else {+ console.log('Failed')+ return new Response(await res.text(), {+ status: 400,+ })+ }+})