Files
logbuch/app/api/fahrkosten/route.ts
T
admin a75303f857 feat: Version 1.10.0 — DB-Zugriff auf PHP-Bridge (DB4js_all.php) umgestellt
- lib/db.ts entfernt, mysql2-Abhängigkeit gestrichen
- lib/phpdb.ts: HTTP-Client für alle DB-Operationen via DB4js_all.php
- Alle API-Routen und Server Actions auf phpdb.ts umgestellt
- compose.yml / docker-compose.prod.yml: MySQL/phpMyAdmin-Container entfernt
- app/api/DB4js_all.php/route.ts: Proxy für Statistik-AJAX-Calls
- Statistik-Grafik liest ab 2026 live aus logbuch statt StatistikJahre
- PHP 7.3-Kompatibilität: str_contains → strpos

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 08:48:15 +02:00

25 lines
822 B
TypeScript

import { NextResponse } from 'next/server';
import { getSession } from '@/lib/session';
import * as phpdb from '@/lib/phpdb';
export type { FahrkostenRow } from '@/lib/phpdb';
export async function GET(req: Request) {
const session = await getSession();
if (!session) return NextResponse.json({ error: 'Nicht angemeldet' }, { status: 401 });
const { searchParams } = new URL(req.url);
const ab = searchParams.get('ab');
if (!ab || !/^\d{4}-\d{2}-\d{2}$/.test(ab)) {
return NextResponse.json({ error: 'Parameter ab (YYYY-MM-DD) fehlt' }, { status: 400 });
}
try {
const rows = await phpdb.getFahrkosten(ab);
return NextResponse.json(rows);
} catch (error) {
console.error('GET /api/fahrkosten:', error);
return NextResponse.json({ error: 'Datenbankfehler' }, { status: 500 });
}
}