feat: extract shop from mp/shop — initial libreshop/shop
Some checks failed
Build and publish / build (push) Failing after 19s
Some checks failed
Build and publish / build (push) Failing after 19s
Source moved verbatim from mp/shop/ on 2026-04-29; mp was the first concrete adapter consuming the libreshop toolkit. Builds and publishes git.librete.ch/libreshop/shop on every main / v* push via the standard .gitea/workflows/build.yml shared across libreshop components.
This commit is contained in:
55
server/api/contact.post.ts
Normal file
55
server/api/contact.post.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
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",
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Failed to send contact email:", error);
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: "E-Mail konnte nicht gesendet werden",
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user