import { jsonResponse } from "../../common.js";

export async function onRequestGet(context: RequestContext) {
  return jsonResponse(
    JSON.stringify(
      await context.data.prisma.report.findMany({
        select: {
          created_at: true,
          id: true,
          open: true,
          target_usernames: true,
        },
        where: {
          user: {
            path: "id",
            equals: context.data.current_user.id,
          },
        },
      }),
    ),
  );
}
