import { NextRequest } from "next/server";

import { proxyHermesRequest } from "@/lib/server/hermes-proxy";
import { assertSameOrigin } from "@/lib/server/request-guards";

export async function GET(request: NextRequest) {
  return proxyHermesRequest(request, `/repairs${request.nextUrl.search}`);
}

export async function POST(request: NextRequest) {
  const originError = assertSameOrigin(request);

  if (originError) {
    return originError;
  }

  return proxyHermesRequest(request, "/repairs");
}
