Add account hierarchy framework with migrations, RLS policies, and UI components
This commit is contained in:
@@ -1,27 +1,40 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { getLogger } from '@kit/shared/logger';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const logger = await getLogger();
|
||||
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { recipientEmail, name, email, subject, message } = body;
|
||||
|
||||
if (!email || !message) {
|
||||
return NextResponse.json({ error: 'E-Mail und Nachricht sind erforderlich' }, { status: 400 });
|
||||
return NextResponse.json(
|
||||
{ error: 'E-Mail und Nachricht sind erforderlich' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
return NextResponse.json({ error: 'Ungültige E-Mail-Adresse' }, { status: 400 });
|
||||
return NextResponse.json(
|
||||
{ error: 'Ungültige E-Mail-Adresse' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
// In production: use @kit/mailers to send the email
|
||||
// For now: log and return success
|
||||
console.log('[contact] Form submission:', {
|
||||
to: recipientEmail || 'admin',
|
||||
from: email,
|
||||
name,
|
||||
subject: subject || 'Kontaktanfrage',
|
||||
message,
|
||||
});
|
||||
logger.info(
|
||||
{
|
||||
to: recipientEmail || 'admin',
|
||||
from: email,
|
||||
name,
|
||||
subject: subject || 'Kontaktanfrage',
|
||||
message,
|
||||
},
|
||||
'[contact] Form submission',
|
||||
);
|
||||
|
||||
// TODO: Wire to @kit/mailers
|
||||
// const mailer = await getMailer();
|
||||
@@ -34,7 +47,7 @@ export async function POST(request: Request) {
|
||||
|
||||
return NextResponse.json({ success: true, message: 'Nachricht gesendet' });
|
||||
} catch (err) {
|
||||
console.error('[contact] Error:', err);
|
||||
logger.error({ error: err, context: 'contact' }, '[contact] Error');
|
||||
return NextResponse.json({ error: 'Serverfehler' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user