From 4838df315931bb883f704ec3e1abe2685f296cdf Mon Sep 17 00:00:00 2001
From: HsiangNianian <admin@jyunko.cn>
Date: Sat, 22 Apr 2023 19:52:26 +0800
Subject: 😀
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 docs/pages/api/signup.tsx | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 docs/pages/api/signup.tsx

(limited to 'docs/pages/api/signup.tsx')

diff --git a/docs/pages/api/signup.tsx b/docs/pages/api/signup.tsx
new file mode 100644
index 0000000..0a082ee
--- /dev/null
+++ b/docs/pages/api/signup.tsx
@@ -0,0 +1,33 @@
+import { NextApiRequest, NextApiResponse } from "next";
+import { withSentry } from "@sentry/nextjs";
+
+const CAMPAIGN_ID = process.env.TURBOREPO_SFDC_CAMPAIGN_ID;
+const TRAY_URL = process.env.TRAY_URL;
+
+async function handler(req: NextApiRequest, res: NextApiResponse) {
+  if (req.method === "POST") {
+    const user = {
+      email: req.body.email,
+      campaign_id: CAMPAIGN_ID,
+    };
+
+    try {
+      const trayRes = await fetch(TRAY_URL, {
+        method: "POST",
+        headers: {
+          "Content-Type": "application/json",
+          Accept: "application/json",
+        },
+        body: JSON.stringify({ user: user }),
+      });
+
+      return res.status(201).json(user);
+    } catch (error) {
+      return res.status(500).json(error);
+    }
+  } else {
+    return res.status(404).send(null);
+  }
+}
+
+export default withSentry(handler);
-- 
cgit v1.2.3-70-g09d2

