API work on SongbookSongs
This commit is contained in:
1 parent
4bdf03426c
commit
b060ab29cf
10 files changed
+347
-119
No files matched your search
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
|
||||
import { getSongBooks, searchSongBooksByTitle, createSongBook } from "@/lib/db/songbook";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks:
|
||||
@@ -18,7 +19,9 @@ export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const query = searchParams.get("query") || searchParams.get("q");
|
||||
|
||||
|
||||
// Wenn ein Suchbegriff übergeben wurde -> Sucheinbindung
|
||||
|
||||
if (query) {
|
||||
const res = await searchSongBooksByTitle(query); // You can enter a limit
|
||||
|
||||
@@ -60,9 +63,9 @@ export async function GET(request: Request) {
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - name
|
||||
* - title
|
||||
* properties:
|
||||
* name:
|
||||
* title:
|
||||
* type: string
|
||||
* example: "Feiert Jesus 1"
|
||||
* language:
|
||||
@@ -92,7 +95,7 @@ export async function GET(request: Request) {
|
||||
* type: string
|
||||
* example: "DE"
|
||||
* 400:
|
||||
* description: Bad Request (missing name)
|
||||
* description: Bad Request (missing title)
|
||||
* 409:
|
||||
* description: Conflict (title already exists)
|
||||
* 500:
|
||||
@@ -102,9 +105,9 @@ export async function POST(request: Request) {
|
||||
try {
|
||||
const data = await request.json();
|
||||
|
||||
if (!data.name || !data.language) {
|
||||
if (!data.title || !data.language) {
|
||||
return NextResponse.json(
|
||||
{ message: "Field 'name' and 'language' are required" },
|
||||
{ message: "Field 'title' and 'language' are required" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user