import { NextRequest, NextResponse } from 'next/server'; import { getSession } from '@/lib/session'; import * as phpdb from '@/lib/phpdb'; export async function GET(request: NextRequest) { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 }); const { searchParams } = new URL(request.url); const year = parseInt(searchParams.get('year') || String(new Date().getFullYear()), 10); try { const result = await phpdb.getStatistik(year); return NextResponse.json(result); } catch (error) { console.error('GET /api/statistik:', error); return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 }); } }