v0.1.2: checkout fixes for CMS v0.2.0 (#18)
build / test (push) Successful in 10s
build / build (push) Successful in 1m5s

Co-authored-by: Michael Czechowski <mail@librete.ch>
This commit was merged in pull request #18.
This commit is contained in:
libretech authored and Michael Czechowski committed 2026-10-15 10:23:27 +02:00
1 parent 60b8f1ab58
commit fccff147ba
29 files changed
+1108 -71

No files matched your search

+7 -44
View File
@@ -1,55 +1,18 @@
import { contactMail, mailSendUrl } from "~/server/utils/contactMail";
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const { name, email, subject, message } = body;
if (!name || !email || !message) {
throw createError({
statusCode: 400,
message: "Name, E-Mail und Nachricht sind erforderlich",
});
}
// Validate email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
throw createError({
statusCode: 400,
message: "Ungültige E-Mail-Adresse",
});
const result = contactMail(await readBody(event));
if (result.ok === false) {
throw createError({ statusCode: 400, message: result.message });
}
try {
// Send email via Mail service
const config = useRuntimeConfig();
const mailApiUrl = config.mailApiUrl || "http://mail:2222";
await $fetch(`${mailApiUrl}/send`, {
method: "POST",
body: {
to: "paperwork@muellerprints.de",
subject: `Kontaktanfrage: ${subject || "Anfrage über Website"}`,
body: `
Name: ${name}
E-Mail: ${email}
Betreff: ${subject || "Kontaktanfrage über Website"}
Nachricht:
${message}
---
Diese Nachricht wurde über das Kontaktformular auf muellerprints.de gesendet.
`.trim(),
replyTo: email,
},
});
await $fetch(mailSendUrl(config.mailApiUrl || "http://mail:2222"), { method: "POST", body: result.mail });
return { success: true };
} catch (error) {
console.error("Failed to send contact email:", error);
throw createError({
statusCode: 500,
message: "E-Mail konnte nicht gesendet werden",
});
throw createError({ statusCode: 500, message: "E-Mail konnte nicht gesendet werden" });
}
});