Files
claude_mac/lib/tests/fixtures/guardrails-good/supabase/functions/notify/index.ts
T
bchanot 558c49e1a1 feat(guardrails): secure-by-default rule and /guardrails scanner
Always-on rules/secure-by-default.md: hosting, a11y, Supabase RLS,
SMS/email consent, cloud functions, API hygiene incl. password storage.
Stdlib scanner (FAIL/WARN/MANUAL) + skill, 89-check suite, auditor
gate wiring, profiles, routing row (plus Explore rows confirmed
through the router dialog).
2026-10-18 18:10:20 +02:00

23 lines
649 B
TypeScript

import { Resend } from "npm:resend";
const resend = new Resend(Deno.env.get("RESEND_API_KEY"));
Deno.serve(async (request) => {
const user = await getUser(request);
const contact = await loadContact(user.id);
if (!contact.consent_at || contact.unsubscribed_at) {
return new Response("skipped");
}
const link = unsubscribeUrl(contact.id);
await resend.emails.send({
to: contact.email,
subject: "News",
html: `<p>Hello</p><a href="${link}">Unsubscribe</a>`,
headers: {
"List-Unsubscribe": `<${link}>`,
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
},
});
return new Response("sent");
});