mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 20:51:18 +00:00
see comments
This commit is contained in:
parent
3fa4da6f9a
commit
349d69baf5
1 changed files with 14 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue