add public feedback/contact option
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m5s

This commit is contained in:
2024-11-30 03:00:46 +01:00
parent ceaf006dd5
commit 55798fd294
10 changed files with 175 additions and 28 deletions

View File

@ -0,0 +1,20 @@
import type { RequestHandler } from '@sveltejs/kit';
import { Feedback } from '$lib/server/database';
import { FeedbackSubmitSchema } from './schema';
import crypto from 'crypto';
export const POST = (async ({ request }) => {
const parseResult = await FeedbackSubmitSchema.safeParseAsync(await request.json());
if (!parseResult.success) {
return new Response(null, { status: 400 });
}
const data = parseResult.data;
await Feedback.create({
event: `website-${data.type}`,
content: data.content,
url_hash: crypto.randomBytes(18).toString('hex')
});
return new Response(null, { status: 200 });
}) satisfies RequestHandler;