From 84194a3c4a3a78baa36906adc3aa90eec2855940 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 5 Nov 2025 17:18:15 +0000 Subject: [PATCH] Remove duplicate Discord endpoint definition cgen-76a55cd61e8e49599a2a62e91298be3f --- server/index.ts | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/server/index.ts b/server/index.ts index 40bf0d17..98d60520 100644 --- a/server/index.ts +++ b/server/index.ts @@ -77,52 +77,6 @@ export function createServer() { res.json({ message: ping }); }); - // Discord Interactions Endpoint (for Activity verification) - app.post("/api/discord/interactions", (req, res) => { - const signature = req.get("x-signature-ed25519"); - const timestamp = req.get("x-signature-timestamp"); - const body = req.rawBody || JSON.stringify(req.body); - - const publicKey = process.env.DISCORD_PUBLIC_KEY; - if (!publicKey) { - console.warn("[Discord] DISCORD_PUBLIC_KEY not configured"); - return res.status(401).json({ error: "Public key not configured" }); - } - - if (!signature || !timestamp) { - return res.status(401).json({ error: "Missing signature or timestamp" }); - } - - // Verify request signature - try { - const verifier = createVerify("ed25519"); - verifier.update(`${timestamp}${body}`); - const isValid = verifier.verify(publicKey, Buffer.from(signature, "hex")); - - if (!isValid) { - return res.status(401).json({ error: "Invalid signature" }); - } - } catch (e: any) { - console.error("[Discord] Signature verification failed:", e?.message); - return res.status(401).json({ error: "Signature verification failed" }); - } - - const interaction = req.body; - - // Handle PING interaction (Discord Activity verification) - if (interaction.type === 1) { - return res.json({ type: 1 }); - } - - // Handle other interaction types - if (interaction.type === 2 || interaction.type === 3 || interaction.type === 4 || interaction.type === 5) { - // For now, acknowledge other interactions - return res.json({ type: 4, data: { content: "Activity received your interaction" } }); - } - - return res.status(400).json({ error: "Unknown interaction type" }); - }); - // DevConnect REST proxy (GET only) app.get("/api/devconnect/rest/:table", async (req, res) => { try {