Working on Standartisation.... #TODO
This commit is contained in:
1 parent
da4d67ea47
commit
bdc864cf94
8 files changed
+104
-36
No files matched your search
@@ -1,6 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongBookById, updateSongBook, deleteSongBook } from "@/lib/db/songbook";
|
||||
// import { parseInt } from "@/lib/helper/checkvar";
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{
|
||||
songBookId: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
@@ -28,12 +33,12 @@ import { getSongBookById, updateSongBook, deleteSongBook } from "@/lib/db/songbo
|
||||
*/
|
||||
|
||||
|
||||
export async function GET(request: Request, { params }) {
|
||||
export async function GET(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId } = await params;
|
||||
|
||||
|
||||
const res = await getSongBookById(songBookId);
|
||||
const res = await getSongBookById(parseInt(songBookId));
|
||||
|
||||
|
||||
if (!res.success) {
|
||||
@@ -81,11 +86,11 @@ export async function GET(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }) {
|
||||
export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId } = await params;
|
||||
const data = await request.json();
|
||||
const res = await updateSongBook(songBookId, data);
|
||||
const res = await updateSongBook(parseInt(songBookId), data);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -126,10 +131,10 @@ export async function PATCH(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function DELETE(request: Request, { params }) {
|
||||
export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId } = await params;
|
||||
const res = await deleteSongBook(songBookId);
|
||||
const res = await deleteSongBook(parseInt(songBookId));
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { addSongToBook, updateSongInBook, removeSongFromBook } from "@/lib/db/songbooksongs";
|
||||
// import { parseInt } from "@/lib/helper/checkvar";
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{
|
||||
songBookId: string;
|
||||
songId: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
@@ -45,13 +51,13 @@ import { addSongToBook, updateSongInBook, removeSongFromBook } from "@/lib/db/so
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function POST(request: Request, { params }) {
|
||||
export async function POST(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId, songId } = await params;
|
||||
const data = await request.json();
|
||||
|
||||
|
||||
const res = await addSongToBook(songId, songBookId, data.number);
|
||||
const res = await addSongToBook(parseInt(songId), parseInt(songBookId), String(data.number));
|
||||
|
||||
|
||||
if (!res.success) {
|
||||
@@ -114,11 +120,11 @@ export async function POST(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }) {
|
||||
export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId, songId } = await params;
|
||||
const data = await request.json();
|
||||
const res = await updateSongInBook(songId, songBookId, data);
|
||||
const res = await updateSongInBook(parseInt(songId), parseInt(songBookId), data);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -165,11 +171,11 @@ export async function PATCH(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function DELETE(request: Request, { params }) {
|
||||
export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId, songId } = await params;
|
||||
|
||||
const res = await removeSongFromBook(songId, songBookId);
|
||||
const res = await removeSongFromBook(parseInt(songId), parseInt(songBookId));
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongByNumber } from "@/lib/db/songbooksongs";
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{
|
||||
songBookId: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
@@ -26,14 +31,14 @@ import { getSongByNumber } from "@/lib/db/songbooksongs";
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function GET(request: Request, { params }) {
|
||||
export async function GET(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId } = await params;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const number = searchParams.get("number") || searchParams.get("n");
|
||||
|
||||
if(number){
|
||||
const res = await getSongByNumber(songBookId, number);
|
||||
const res = await getSongByNumber(parseInt(songBookId), number);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongById, updateSong, deleteSong } from "@/lib/db/song";
|
||||
// import { parseInt } from "@/lib/helper/checkvar";
|
||||
|
||||
interface RouteParams {
|
||||
params: Promise<{
|
||||
songId: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
@@ -27,10 +31,10 @@ import { getSongById, updateSong, deleteSong } from "@/lib/db/song";
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function GET(request: Request, { params }) {
|
||||
export async function GET(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songId } = await params;
|
||||
const res = await getSongById(songId);
|
||||
const res = await getSongById(parseInt(songId));
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -77,11 +81,11 @@ export async function GET(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }) {
|
||||
export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songId } = await params;
|
||||
const data = await request.json();
|
||||
const res = await updateSong(songId, data);
|
||||
const res = await updateSong(parseInt(songId), data);
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
@@ -122,10 +126,10 @@ export async function PATCH(request: Request, { params }) {
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
*/
|
||||
export async function DELETE(request: Request, { params }) {
|
||||
export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songId } = await params;
|
||||
const res = await deleteSong(songId);
|
||||
const res = await deleteSong(parseInt(songId));
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// @wikiCategory: Stream
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongById } from "@/lib/db/song";
|
||||
import { getSongBookById } from "@/lib/db/songbook";
|
||||
|
||||
|
||||
let currentSong = {
|
||||
@@ -58,8 +56,9 @@ export async function POST(request: Request) {
|
||||
number
|
||||
};
|
||||
|
||||
const payload = JSON.stringify(currentSong);
|
||||
clients.forEach((send) => send(payload));
|
||||
clients.forEach((controller) => {
|
||||
controller.enqueue(`data: ${JSON.stringify(currentSong)}\n\n`);
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true , currentSong }, { status: 200 });
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user