see comments

This commit is contained in:
Rajpreet0 2026-07-28 01:26:12 +02:00
parent 3fa4da6f9a
commit 349d69baf5

View file

@ -6,7 +6,18 @@
import { Resend } from "resend";
export const resend = new Resend(process.env.RESEND_API_KEY);
let resendInstance: Resend | null = null;
/**
* Liefert eine lazy initialisierte Resend-Instanz.
* Verhindert, dass der Build fehlschlägt, wenn RESEND_API_KEY zur Build-Zeit fehlt.
*/
export function getResend(): Resend {
if (!resendInstance) {
resendInstance = new Resend(process.env.RESEND_API_KEY);
}
return resendInstance;
}
/**
* Sendet eine E-Mail
@ -29,7 +40,7 @@ export async function sendMail({
text?: string;
}) {
try {
const { data, error } = await resend.emails.send({
const { data, error } = await getResend().emails.send({
from: process.env.RESEND_FROM || "",
to,
subject,
@ -69,6 +80,6 @@ export async function verifyMailConnection() {
return false;
}
console.log("Resend-Konfiguration vorhanden");
console.log("Resend-Konfiguration vollständig");
return true;
}