import { getServerSession } from "next-auth";
import { authOptions } from "./auth-options";

/**
 * Get the authenticated session, or null if not authenticated.
 * Usage in API routes:
 *   const session = await getAuthSession();
 *   if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
 */
export async function getAuthSession() {
  return getServerSession(authOptions);
}
