import { NextResponse } from 'next/server'; import { getCurrentUser } from '@/lib/auth'; import type { GetCurrentUserResponse, GetCurrentUserError401 } from '@/types/api-types'; export async function GET() { try { const user = await getCurrentUser(); if (!user) { const error: GetCurrentUserError401 = { error: 'Not authenticated' }; return NextResponse.json(error, { status: 401 }); } const response: GetCurrentUserResponse = { id: user.id, email: user.email, name: user.name, createdAt: user.createdAt.toISOString(), }; return NextResponse.json(response, { status: 200 }); } catch (error) { console.error('Get current user error:', error); return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); } }