import { getServerSession } from "next-auth"; import { authOptions } from "../../auth/[...nextauth]/route"; import { NextResponse } from "next/server"; import { queries } from "@/lib/queries"; export async function GET() { const session = await getServerSession(authOptions); if (!session?.user.id) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } const user = await queries.fetchCurrentUser(session.user.id) if (!user) { return NextResponse.json({ error: 'User not found' }, { status: 404 }); } return NextResponse.json(user); }