Skip to article
Documentation

src/app/api/reviews/route.ts

Linked repository file from this build.

import { NextResponse } from "next/server";
import { apiRoute } from "@/lib/api-route";
import { queryReviewVersions } from "@/lib/db/review-store";
import { getActor } from "@/lib/auth/server";
import { AccessError, can } from "@/lib/auth/scope";
export const dynamic = "force-dynamic";
export const GET = apiRoute("Unable to check saved reviews.", async (request) => {
  const actor = await getActor(request);
  if (!can(actor, "report")) throw new AccessError("This role cannot load reports.");
  return NextResponse.json(await queryReviewVersions(actor));
});