fix:manage edit for extra bezoekers payments
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import { env } from "@kk/env/server";
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
function createTransport() {
|
||||
// Singleton transport — created once per module, reused across all email sends.
|
||||
// Re-creating it on every call causes EventEmitter listener accumulation in
|
||||
// long-lived Cloudflare Worker processes, triggering memory leak warnings.
|
||||
let _transport: nodemailer.Transporter | null | undefined;
|
||||
|
||||
function getTransport(): nodemailer.Transporter | null {
|
||||
if (_transport !== undefined) return _transport;
|
||||
if (!env.SMTP_HOST || !env.SMTP_USER || !env.SMTP_PASS) {
|
||||
_transport = null;
|
||||
return null;
|
||||
}
|
||||
return nodemailer.createTransport({
|
||||
_transport = nodemailer.createTransport({
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
secure: env.SMTP_PORT === 465,
|
||||
@@ -14,6 +21,7 @@ function createTransport() {
|
||||
pass: env.SMTP_PASS,
|
||||
},
|
||||
});
|
||||
return _transport;
|
||||
}
|
||||
|
||||
const from = env.SMTP_FROM ?? "Kunstenkamp <info@kunstenkamp.be>";
|
||||
@@ -223,7 +231,7 @@ export async function sendConfirmationEmail(params: {
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
}) {
|
||||
const transport = createTransport();
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping confirmation email");
|
||||
return;
|
||||
@@ -249,7 +257,7 @@ export async function sendUpdateEmail(params: {
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
}) {
|
||||
const transport = createTransport();
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping update email");
|
||||
return;
|
||||
@@ -272,7 +280,7 @@ export async function sendCancellationEmail(params: {
|
||||
to: string;
|
||||
firstName: string;
|
||||
}) {
|
||||
const transport = createTransport();
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping cancellation email");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user