stevekrouse-handlediscordnewuser.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
// # 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): Promise<Response> {
// check custom auth secret sent from clerk
if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))
return new Response("Unauthorized", { "status": 401 });
const body = await req.json();
await discordWebhook({
url: Deno.env.get("discordUserEvents"),
content: body.data.email_addresses[0].email_address
+ " "
+ body.data.profile_image_url,
});
return new Response("Success");
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v18
March 15, 2024