first commit

This commit is contained in:
robin committed 2026-07-03 16:23:04 +02:00
commit 7bf0cb4f05
27 files changed
+5490

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { NextResponse } from "next/server";
import { getSongbooks, addSongbook } from "@/lib/db/managing";
export async function GET() {
try {
const songbooks = await getSongbooks();
return NextResponse.json(songbooks);
} catch (error) {
return NextResponse.json({ success: false, message: error}, { status: 500})
}
}
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 })
}
}