import { NextResponse } from 'next/server'; import { getCurrentUser } from '@/lib/auth/session'; import { unreadCount } from '@/lib/account/queries'; export const dynamic = 'force-dynamic'; /** GET /api/auth/session — lightweight identity for client components (header user menu). */ export async function GET() { const u = await getCurrentUser(); if (!u) return NextResponse.json({ user: null }, { headers: { 'cache-control': 'private, no-store' } }); const unread = await unreadCount(u.id); return NextResponse.json({ user: { id: u.id, email: u.email, name: u.name, handle: u.handle, avatarUrl: u.avatarUrl, displayCurrency: u.displayCurrency, role: u.role }, unread }, { headers: { 'cache-control': 'private, no-store' } }); }