Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Update env

Tomas Valentac31817cc6027
diff --git a/dbk.toml b/dbk.toml
index 21c231442..06ebec411 100644
--- a/dbk.toml
+++ b/dbk.toml
@@ -2,7 +2,7 @@
title = "ai-api"
template = "Nodejs"
-id = "KctyCCI7Ijf9"
+id = "QfqlXmCo5iKl"
[filesystem]
-local_root = "./files"
\ No newline at end of file
+local_root = "./files"
diff --git a/files/in.ts b/files/in.ts
new file mode 100644
index 000000000..0be7f5133
--- /dev/null
+++ b/files/in.ts
@@ -0,0 +1,21 @@
+import { Router, Response } from 'itty-router'
+import { isEmail } from 'validator'
+import { db } from 'supabase'
+
+const router = Router()
+
+async function handlepostRequest(request, env) {
+ const { email } = await request.json()
+ if (!isEmail(email)) {
+ return new Response(JSON.stringify({ error: 'Invalid email' }), { status: 400 })
+ }
+ await db.query(`INSERT INTO users (email) VALUES ($1)`, [email])
+ return new Response(JSON.stringify({ message: 'Ok' }))
+}
+
+router.post('/', handlepostRequest)
+router.get('*', () => new Response('Not found', { status: 404 }))
+
+export default {
+ fetch: router.handle
+}