Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.3 kB ยท 55 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import type React from "react";import { render } from "react-email";import { Resend } from "resend";
import { env } from "./env";
export const resend = new Resend(env.RESEND_API_KEY);
export interface Emails { react: React.JSX.Element; subject: string; to: string[]; from: string; reply_to?: string;}
export type EmailHtml = { html: string; subject: string; to: string; from: string; reply_to?: string;};export const sendEmail = async (email: Emails) => { if (env.NODE_ENV !== "production") return; await resend.emails.send(email);};
export const sendBatchEmailHtml = async (emails: EmailHtml[]) => { if (env.NODE_ENV !== "production") return; await resend.batch.send(emails);};
// TODO: delete in favor of sendBatchEmailHtmlexport const sendEmailHtml = async (emails: EmailHtml[]) => { if (env.NODE_ENV !== "production") return;
await fetch("https://api.resend.com/emails/batch", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${env.RESEND_API_KEY}`, }, body: JSON.stringify(emails), });};
export const sendWithRender = async (email: Emails) => { if (env.NODE_ENV !== "production") return; const html = await render(email.react); await resend.emails.send({ ...email, html, });};