import { NextResponse } from 'next/server'; import { query } from '@/lib/db'; import { getSession } from '@/lib/session'; export async function GET() { const session = await getSession(); if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 }); try { const rows = await query('SELECT ID, Name FROM objekte ORDER BY LastUsed DESC LIMIT 100'); return NextResponse.json(rows); } catch (error) { console.error('GET /api/objekte:', error); return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 }); } }