Added Status takes from helpermethods

Die Helfermethoden (/lib/db/*) bieten Statuscodes, welche hier übernommen wurden.
This commit is contained in:
rudi committed 2026-07-31 16:00:40 +02:00
1 parent 25a253116c
commit e81e6b5743
1 file changed
+6 -6
+6 -6
View File
@@ -27,20 +27,20 @@ export async function GET(request: Request) {
const res = await searchSongBooksByTitle(query); // You can enter a limit
if (!res.success) {
return NextResponse.json({ message: res.error }, { status: 500 });
return NextResponse.json({ message: res.error }, { status: res.status });
}
return NextResponse.json(res.songBooks, { status: 200 });
return NextResponse.json(res.songBooks, { status: res.status };
}
// Ansonsten alle Bücher abrufen
const res = await getSongBooks();
if (!res.success) {
return NextResponse.json({ message: res.error }, { status: 500 });
return NextResponse.json({ message: res.error }, { status: res.status });
}
return NextResponse.json(res.songBooks, { status: 200 });
return NextResponse.json(res.songBooks, { status: res.status });
} catch (error) {
console.error("GET /api/songbooks error:", error);
@@ -123,11 +123,11 @@ export async function POST(request: Request) {
if (!res.success) {
return NextResponse.json(
{ message: res.error },
{ status: res.status | 500} // ALERT-TODO Implement!!!
{ status: res.status }
);
}
return NextResponse.json(res, { status: 201 });
return NextResponse.json(res, { status: res.status });
} catch (error) {
console.error("POST /api/songbooks error:", error);