const resendSecret = Deno.env.get("RESEND_SECRET") const resendApiKey = Deno.env.get("RESEND_API_KEY") const handler = async (request: Request): Promise => { const { estimate_min, estimate_max, position, secret, email } = await request.json() if (secret !== resendSecret) { return new Response(JSON.stringify("too bad"), { status: 403, headers: { "Content-Type": "application/json", }, }) } const res = await fetch("https://api.resend.com/emails", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${resendApiKey}`, }, body: JSON.stringify({ from: "Union Ceremony ", to: [email], reply_to: "ceremony@union.build", subject: "Your Turn Is Almost Here - Log Into Union Ceremony", html: `

Your contribution slot for the Union Trusted Setup Ceremony is almost here.

Your place in queue: ${position}
Estimated time until your slot: between ${estimate_min} and ${estimate_max}

Please go to ceremony.union.build, log in, and follow all steps on the page.
If you do not follow all steps by the time your contribution slot arrives, you will lose your slot.

`, }), }) return new Response(JSON.stringify(data), { status: res.status, headers: { "Content-Type": "application/json", }, }) } Deno.serve(handler)