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:
parent
7f0a586311
commit
1c8f30fe6f
1 changed files with 16 additions and 10 deletions
|
|
@ -63,10 +63,15 @@ export default defineEventHandler(async (event) => {
|
||||||
.replace(/\n/g, '<br>')
|
.replace(/\n/g, '<br>')
|
||||||
.replace(/\{acceptLink\}/g, acceptButton)
|
.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({
|
const { error: emailError } = await resend.emails.send({
|
||||||
from: 'Ghost Guild <welcome@babyghosts.org>',
|
from: 'Ghost Guild <welcome@babyghosts.org>',
|
||||||
to: [preReg.email],
|
to: [preReg.email],
|
||||||
subject: "You're invited to Ghost Guild! 👻",
|
subject,
|
||||||
text: emailText,
|
text: emailText,
|
||||||
html: emailHtml,
|
html: emailHtml,
|
||||||
})
|
})
|
||||||
|
|
@ -75,6 +80,7 @@ export default defineEventHandler(async (event) => {
|
||||||
results.push({ preRegistrantId: preReg._id, email: preReg.email, success: false, error: emailError.message })
|
results.push({ preRegistrantId: preReg._id, email: preReg.email, success: false, error: emailError.message })
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await PreRegistration.findByIdAndUpdate(preReg._id, {
|
await PreRegistration.findByIdAndUpdate(preReg._id, {
|
||||||
$set: {
|
$set: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue