Update API Doc
This commit is contained in:
1 parent
5d6d8f15f3
commit
5a56245218
10 files changed
+1196
-229
No files matched your search
@@ -1,3 +1,5 @@
|
||||
// @/app/api/songbooks/[songBookId]/route.ts
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongBookById, updateSongBook, deleteSongBook } from "@/lib/db/songbook";
|
||||
|
||||
@@ -9,38 +11,51 @@ interface RouteParams {
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks/{id}:
|
||||
* /api/songbooks/{songBookId}:
|
||||
* get:
|
||||
* summary: Einzelnen Songbook abrufen
|
||||
* summary: Einzelnes Songbook abrufen
|
||||
* tags:
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* name: songBookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songbooks
|
||||
* example: 1
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Songbook erfolgreich gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBook'
|
||||
* 400:
|
||||
* description: Ungültige Songbook-ID
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Songbook nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
|
||||
|
||||
export async function GET(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
const { songBookId } = await params;
|
||||
|
||||
|
||||
const res = await getSongBookById(parseInt(songBookId));
|
||||
|
||||
|
||||
if (!res.success) {
|
||||
return NextResponse.json({ message: res.error }, { status: res.status });
|
||||
}
|
||||
@@ -58,33 +73,57 @@ export async function GET(_request: Request, { params }: RouteParams) {
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks/{id}:
|
||||
* /api/songbooks/{songBookId}:
|
||||
* patch:
|
||||
* summary: Songbook aktualisieren
|
||||
* tags:
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* name: songBookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songbooks
|
||||
* example: 1
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* title:
|
||||
* type: string
|
||||
* example: "Feiert Jesus 1"
|
||||
* language:
|
||||
* type: string
|
||||
* example: "DE"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Songbook erfolgreich aktualisiert
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBook'
|
||||
* 400:
|
||||
* description: Ungültige Parameter oder Daten
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Songbook nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
@@ -100,7 +139,7 @@ export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
} catch (error) {
|
||||
console.error("API Error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Fehler beim Laden der Songbookinfos" },
|
||||
{ error: "Fehler beim Aktualisieren des Songbooks" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
@@ -109,27 +148,44 @@ export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks/{id}:
|
||||
* /api/songbooks/{songBookId}:
|
||||
* delete:
|
||||
* summary: Songbook löschen
|
||||
* tags:
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* name: songBookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songbooks
|
||||
* example: 1
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Songbook erfolgreich gelöscht
|
||||
* description: Songbook erfolgreich gelöscht (gibt das gelöschte Songbook zurück)
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBook'
|
||||
* 400:
|
||||
* description: Ungültige Songbook-ID
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Songbook nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
@@ -144,7 +200,7 @@ export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
} catch (error) {
|
||||
console.error("API Error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Fehler beim Laden der Songbookinfos" },
|
||||
{ error: "Fehler beim Löschen des Songbooks" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @/app/api/songbooks/[songBookId]/songs/[songId]/route.ts
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { addSongToBook, updateSongInBook, removeSongFromBook } from "@/lib/db/songbooksongs";
|
||||
|
||||
@@ -14,7 +16,7 @@ interface RouteParams {
|
||||
* post:
|
||||
* summary: Song zu Liederbuch hinzufügen
|
||||
* tags:
|
||||
* - Songbook
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: songBookId
|
||||
@@ -22,12 +24,14 @@ interface RouteParams {
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Liederbuchs
|
||||
* example: 1
|
||||
* - in: path
|
||||
* name: songId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songs
|
||||
* example: 1
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
@@ -44,12 +48,28 @@ interface RouteParams {
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Song erfolgreich zugewiesen
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBookEntry'
|
||||
* 400:
|
||||
* description: Ungültige Parameter oder fehlende Songnummer
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 409:
|
||||
* description: Songnummer bereits vergeben oder Song existiert bereits im Buch
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function POST(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
@@ -68,7 +88,7 @@ export async function POST(request: Request, { params }: RouteParams) {
|
||||
} catch (error) {
|
||||
console.error("API Error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Fehler beim Laden der Songbookinfos" },
|
||||
{ error: "Fehler beim Zuweisen des Songs" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
@@ -81,7 +101,7 @@ export async function POST(request: Request, { params }: RouteParams) {
|
||||
* patch:
|
||||
* summary: Songnummer eines Songs im Liederbuch aktualisieren
|
||||
* tags:
|
||||
* - Songbook
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: songBookId
|
||||
@@ -89,12 +109,14 @@ export async function POST(request: Request, { params }: RouteParams) {
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Liederbuchs
|
||||
* example: 1
|
||||
* - in: path
|
||||
* name: songId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songs
|
||||
* example: 1
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
@@ -111,14 +133,34 @@ export async function POST(request: Request, { params }: RouteParams) {
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Songnummer erfolgreich aktualisiert
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBookEntry'
|
||||
* 400:
|
||||
* description: Ungültige Parameter oder fehlende Daten
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Zuweisung nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 409:
|
||||
* description: Neue Songnummer bereits vergeben
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
@@ -134,7 +176,7 @@ export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
} catch (error) {
|
||||
console.error("API Error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Fehler beim Laden der Songbookinfos" },
|
||||
{ error: "Fehler beim Aktualisieren der Songnummer" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
@@ -147,7 +189,7 @@ export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
* delete:
|
||||
* summary: Song aus Liederbuch entfernen
|
||||
* tags:
|
||||
* - Songbook
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: songBookId
|
||||
@@ -155,21 +197,39 @@ export async function PATCH(request: Request, { params }: RouteParams) {
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Liederbuchs
|
||||
* example: 1
|
||||
* - in: path
|
||||
* name: songId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songs
|
||||
* example: 1
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Song erfolgreich aus dem Liederbuch entfernt
|
||||
* description: Song erfolgreich aus dem Liederbuch entfernt (gibt die entfernte Zuweisung zurück)
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBookEntry'
|
||||
* 400:
|
||||
* description: Ungültige Parameter
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Zuweisung nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
@@ -185,7 +245,7 @@ export async function DELETE(_request: Request, { params }: RouteParams) {
|
||||
} catch (error) {
|
||||
console.error("API Error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Fehler beim Laden der Songbookinfos" },
|
||||
{ error: "Fehler beim Entfernen des Songs" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @/app/api/songbooks/[songBookId]/songs/route.ts
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongByNumber } from "@/lib/db/songbooksongs";
|
||||
|
||||
@@ -9,27 +11,58 @@ interface RouteParams {
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks/{id}/songs:
|
||||
* /api/songbooks/{songBookId}/songs:
|
||||
* get:
|
||||
* summary: Einen Song nach Nummer in einem Songbook suchen
|
||||
* tags:
|
||||
* - Songbook
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* name: songBookId
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Die ID des Songbooks
|
||||
* example: 1
|
||||
* - in: query
|
||||
* name: number
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Die Nummer des Songs im Songbook
|
||||
* example: "123"
|
||||
* - in: query
|
||||
* name: n
|
||||
* required: false
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Alias für `number`
|
||||
* example: "123"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Songbook erfolgreich gefunden
|
||||
* description: Song im Songbook erfolgreich gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/SongBookEntry'
|
||||
* 400:
|
||||
* description: Ungültige Songbook-ID
|
||||
* description: Ungültige Songbook-ID oder fehlender number-Parameter
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 404:
|
||||
* description: Songbook nicht gefunden
|
||||
* description: Songbook oder Song nicht gefunden
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function GET(request: Request, { params }: RouteParams) {
|
||||
try {
|
||||
|
||||
+47
-21
@@ -1,22 +1,45 @@
|
||||
// @wikiCategory: Liederbücher
|
||||
// @/app/api/songbooks/route.ts
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongBooks, searchSongBooksByTitle, createSongBook } from "@/lib/db/songbook";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /api/songbooks:
|
||||
* get:
|
||||
* summary: Get all songbooks
|
||||
* summary: Get all songbooks or search songbooks by title
|
||||
* tags:
|
||||
* - Songbooks
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: query
|
||||
* required: false
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Search term for the songbook title
|
||||
* example: "Feiert Jesus"
|
||||
* - in: query
|
||||
* name: q
|
||||
* required: false
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Alias for `query`
|
||||
* example: "Feiert Jesus"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List of songbooks
|
||||
* description: List of songbooks (filtered by title if a query is given)
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/SongBook'
|
||||
* 500:
|
||||
* description: Internal Server Error
|
||||
*
|
||||
* @wikiDescription: Liste aller Liederbücher abrufen
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function GET(request: Request) {
|
||||
try {
|
||||
@@ -60,6 +83,8 @@ export async function GET(request: Request) {
|
||||
* /api/songbooks:
|
||||
* post:
|
||||
* summary: Creates a new songbook
|
||||
* tags:
|
||||
* - Songbooks
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
@@ -68,6 +93,7 @@ export async function GET(request: Request) {
|
||||
* type: object
|
||||
* required:
|
||||
* - title
|
||||
* - language
|
||||
* properties:
|
||||
* title:
|
||||
* type: string
|
||||
@@ -87,25 +113,25 @@ export async function GET(request: Request) {
|
||||
* type: boolean
|
||||
* example: true
|
||||
* songBook:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* example: 1
|
||||
* title:
|
||||
* type: string
|
||||
* example: "Feiert Jesus 1"
|
||||
* language:
|
||||
* type: string
|
||||
* example: "DE"
|
||||
* $ref: '#/components/schemas/SongBook'
|
||||
* 400:
|
||||
* description: Bad Request (missing title)
|
||||
* description: Bad Request (missing title or language)
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 409:
|
||||
* description: Conflict (title already exists)
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* 500:
|
||||
* description: Internal Server Error
|
||||
*
|
||||
* @wikiDescription: Neues Liederbuch erstellen
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user