()
| 6 | import { logger } from '@/util/logger' |
| 7 | |
| 8 | export async function GET() { |
| 9 | const session = await getServerSession(authOptions) |
| 10 | |
| 11 | if (!session?.user?.id) { |
| 12 | return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) |
| 13 | } |
| 14 | |
| 15 | const userId = session.user.id |
| 16 | |
| 17 | try { |
| 18 | // Use the new consolidated usage service |
| 19 | const usageData = await getUserUsageData({ userId, logger }) |
| 20 | |
| 21 | return NextResponse.json(usageData) |
| 22 | } catch (error) { |
| 23 | console.error('Error fetching usage data:', error) |
| 24 | return NextResponse.json( |
| 25 | { error: 'Internal server error' }, |
| 26 | { status: 500 }, |
| 27 | ) |
| 28 | } |
| 29 | } |
nothing calls this directly
no test coverage detected