add api route to get all reports
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user