feat(invite): skip Resend dispatch when ALLOW_DEV_TEST_ENDPOINTS=true

Pre-registrant invite was the only email route calling Resend directly
(bypassing server/utils/resend.js), so dev/e2e runs were dispatching
real email. Gate just the network call; DB updates (jti, status,
activity log) still run. Mirrors the bypass pattern in
server/middleware/03.rate-limit.js.

Other email routes via server/utils/resend.js still send live in dev
mode — wrapper refactor tracked in BACKLOG.
This commit is contained in:
Jennie Robinson Faber 2026-04-30 22:25:41 +01:00
parent 7f0a586311
commit 1c8f30fe6f

View file

@ -63,10 +63,15 @@ export default defineEventHandler(async (event) => {
.replace(/\n/g, '<br>')
.replace(/\{acceptLink\}/g, acceptButton)
const subject = "You're invited to Ghost Guild! 👻"
if (process.env.ALLOW_DEV_TEST_ENDPOINTS === 'true') {
console.log('[resend] DEV MODE — skipping invite send', { to: preReg.email, subject })
} else {
const { error: emailError } = await resend.emails.send({
from: 'Ghost Guild <welcome@babyghosts.org>',
to: [preReg.email],
subject: "You're invited to Ghost Guild! 👻",
subject,
text: emailText,
html: emailHtml,
})
@ -75,6 +80,7 @@ export default defineEventHandler(async (event) => {
results.push({ preRegistrantId: preReg._id, email: preReg.email, success: false, error: emailError.message })
continue
}
}
await PreRegistration.findByIdAndUpdate(preReg._id, {
$set: {