API work on SongbookSongs
This commit is contained in:
1 parent
4bdf03426c
commit
b060ab29cf
10 files changed
+347
-119
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongBookById, upateSongBook, deleteSongBook } from "@/lib/db/songbook";
|
||||
import { getSongBookById, updateSongBook, deleteSongBook } from "@/lib/db/songbook";
|
||||
// import { parseInt } from "@/lib/helper/checkvar";
|
||||
|
||||
/**
|
||||
@@ -26,10 +26,15 @@ import { getSongBookById, upateSongBook, deleteSongBook } from "@/lib/db/songboo
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
|
||||
|
||||
export async function GET(request: Request, { params }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const res = await getSongBookById(id);
|
||||
const { songBookId } = await params;
|
||||
|
||||
|
||||
const res = await getSongBookById(songBookId);
|
||||
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -78,9 +83,9 @@ export async function GET(request: Request, { params }) {
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const { songBookId } = await params;
|
||||
const data = await request.json();
|
||||
const res = await upateSongBook(id, data);
|
||||
const res = await updateSongBook(songBookId, data);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -123,8 +128,8 @@ export async function PATCH(request: Request, { params }) {
|
||||
*/
|
||||
export async function DELETE(request: Request, { params }) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const res = await deleteSongBook(id);
|
||||
const { songBookId } = await params;
|
||||
const res = await deleteSongBook(songBookId);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
|
||||
Reference in new issue
Block a user