Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook?v=3";
import process from "node:process";
// # New Val Town User (on Clerk) -> Val Town Discord notification
// Translates one kind of webhook (Clerk) into another (Discord)
export async function handleDiscordNewUser(req: Request) {
// check custom auth secret sent from clerk
if (req.headers.get("auth") !== process.env.clerkNonSensitive)
return new Response("Unauthorized", { status: 401 });
const body = await req.json();
await discordWebhook({
url: process.env.newUserDiscord,
content: body.data.email_addresses[0].email_address +
" " +
body.data.profile_image_url,
});
return new Response("Success");
}
neverstew-handlediscordnewuser.web.val.run
October 23, 2023