import { NextRequest, NextResponse } from 'next/server'; import { getSession } from '@/lib/session'; import { getPause, setPause } from '@/lib/repo'; import { toNumber } from '@/lib/validate'; export async function GET() { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 }); try { return NextResponse.json({ pause: getPause() }); } catch (error) { console.error('GET /api/settings:', error); return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 }); } } export async function PUT(request: NextRequest) { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 }); try { const body = await request.json(); const pause = toNumber(body?.pause, NaN); if (isNaN(pause) || pause < 0 || pause > 24) { return NextResponse.json({ error: 'Ungültiger Pausenwert.' }, { status: 400 }); } setPause(pause); return NextResponse.json({ pause }); } catch (error) { console.error('PUT /api/settings:', error); return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 }); } }