// @wikiCategory: Liederbücher import { NextResponse } from "next/server"; import { getSongbooks, addSongbook } from "@/lib/db/managing"; // @wikiDescription: Liste aller Liederbücher abrufen export async function GET() { try { const songbooks = await getSongbooks(); return NextResponse.json(songbooks); } catch (error) { return NextResponse.json({ success: false, message: error}, { status: 500}) } } // @wikiDescription: Neues Liederbuch erstellen export async function POST(request: Request) { try { const { name, language } = await request.json(); if (!name ) { return NextResponse.json({ success: false, message: "Fields incomplete (name)"}, { status: 400 }) } const newBook = await addSongbook(String(name), String(language)) return NextResponse.json(newBook, { status: 201 }) } catch (error) { return NextResponse.json({ success: false }, { status: 500 }) } }