rework api endpoints
All checks were successful
deploy / build-and-deploy (push) Successful in 19s

This commit is contained in:
2025-10-17 20:15:06 +02:00
parent a27cf5f35b
commit 964ccfacbf
10 changed files with 266 additions and 189 deletions

View File

@@ -0,0 +1,27 @@
import { externalApi } from '../_api.ts';
import { z } from 'astro:schema';
import { db } from '@db/database.ts';
import { BASE_PATH } from 'astro:env/server';
export const POST = externalApi({
input: z.object({
event: z.string(),
title: z.string(),
uuids: z.array(z.string())
}),
auth: true,
handler: async ({ input }) => {
const feedbacks = await db.addUserFeedbacks({
event: input.event,
title: input.title,
uuids: input.uuids
});
const response = feedbacks.map((feedback) => ({
uuid: feedback.uuid,
url: `${BASE_PATH}/feedback/${feedback.urlHash}`
}));
return new Response(JSON.stringify({ feedback: response }), { status: 200 });
}
});