// API route: GET /api/me. Protected by requireAuth — returns 401 when anonymous,
// otherwise the current user hydrated onto ctx by the auth middleware.
import { requireAuth, getUser, type Context } from "@wrnexus/core";

const guard = requireAuth();

export async function GET(ctx: Context): Promise<Response> {
  const denied = await guard(ctx, () => new Response(null));
  if (denied.status === 401) return denied;
  return Response.json({ ok: true, user: getUser(ctx) });
}
