add api route to get all reports
All checks were successful
deploy / build-and-deploy (push) Successful in 30s

This commit is contained in:
2025-12-20 13:22:49 +01:00
parent ce13420116
commit ca88071eba
3 changed files with 69 additions and 105 deletions

View File

@@ -2,6 +2,28 @@ import { externalApi } from '../_api.ts';
import { z } from 'astro:schema';
import { db } from '@db/database.ts';
import { sendWebhook, WebhookAction } from '@util/webhook.ts';
import { BASE_PATH } from 'astro:env/server';
export const GET = externalApi({
auth: true,
handler: async () => {
const reports = await db.getReports({});
return new Response(
JSON.stringify({
reports: reports.map((report) => ({
reporter: report.reporter.uuid,
reported: report.reported?.uuid ?? null,
reason: report.reason,
created: report.createdAt?.getTime() ?? null,
status: report.status?.status ?? null,
url: `${BASE_PATH}/report/${report.urlHash}`
}))
}),
{ status: 200 }
);
}
});
export const POST = externalApi({
input: z.object({