fix:manage edit for extra bezoekers payments

This commit is contained in:
2026-03-03 14:28:59 +01:00
parent 0a1d1db9ec
commit e6f52e6a73
6 changed files with 338 additions and 134 deletions

View File

@@ -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;