import { NextResponse } from "next/server";

import { HttpError, requireAuthContext } from "@/lib/auth/authContext";

export const dynamic = "force-dynamic";

export async function GET() {
  try {
    const auth = await requireAuthContext();
    return NextResponse.json({ ok: true, auth }, { status: 200 });
  } catch (err) {
    const status = err instanceof HttpError ? err.status : 500;
    const message = err instanceof Error ? err.message : "Unknown error";
    return NextResponse.json({ ok: false, error: message }, { status });
  }
}
