Compare commits

..

No commits in common. "5cf33146fe45ffa761963189c442780d02cbb392" and "57d4a095a405ed5fc8b7abb5aa2bee9881e6f959" have entirely different histories.

4 changed files with 27 additions and 12 deletions

View File

@ -39,7 +39,7 @@ curl -X POST http://localhost:3000/api/v1/email \
"language": "en",
"data": {
"name": "John Doe",
"barcode_content": "0123456789",
"barcode_url": "https://barcodeapi.org/api/8/12345670?",
"link": "https://portal.lauf-fuer-kaya.de/"
}
}'
@ -95,7 +95,7 @@ The project uses:
### Welcome Email
- Languages: 🇬🇧 English, 🇩🇪 German
- Variables: `name`, `link`, `barcode_content`
- Variables: `name`, `link`, `barcode_url`
### Password Reset
- Languages: 🇬🇧 English, 🇩🇪 German

View File

@ -17,22 +17,17 @@ const sendEmailSchema = z.object({
})
emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => {
let { to, subject, templateName, language, data } = c.req.valid('json')
const { to, subject, templateName, language, data } = c.req.valid('json')
try {
const template = getEmailTemplate(templateName, language as Language)
if (templateName === "welcome") {
if (data.barcode_content === "0123456789") {
data.barcode_url = "https://barcodeapi.org/api/128/0123456789?"
}
}
await emailService.sendEmail({
to,
subject,
html: template.html(data),
text: template.text(data)
})
return c.json({ success: true })
} catch (error) {
return c.json({ success: false, error: (error as Error).message }, 400)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long