chore: wiki: automatic list of all api endpoints
This commit is contained in:
1 parent
7664d058df
commit
3fc0697db8
11 files changed
+205
-39
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongbooks, addSongbook } from "@/lib/db/managing";
|
||||
|
||||
|
||||
// @wikiDescription: Liste aller Liederbücher abrufen
|
||||
export async function GET() {
|
||||
try {
|
||||
const songbooks = await getSongbooks();
|
||||
@@ -10,6 +10,8 @@ export async function GET() {
|
||||
return NextResponse.json({ success: false, message: error}, { status: 500})
|
||||
}
|
||||
}
|
||||
|
||||
// @wikiDescription: Neues Liederbuch erstellen
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const { name, language } = await request.json();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSongInfos } from "@/lib/db/managing";
|
||||
|
||||
// @wikiDescription: Informationen eines Liedes abrufen
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { attachSongToSongbook } from "@/lib/db/managing";
|
||||
|
||||
// @wikiDescription: Lied zu einem Liederbuch hinzufügen
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { removeSongfromSongbook } from "@/lib/db/managing";
|
||||
|
||||
// @wikiDescription: Lied von einem Liederbuch entfernen
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NextResponse } from "next/server";
|
||||
|
||||
import { getSongs, addSongToSongbook } from "@/lib/db/managing";
|
||||
|
||||
// @wikiDescription: Liste aller Lieder abrufen
|
||||
export async function GET() {
|
||||
const songs = await getSongs();
|
||||
if (songs) {
|
||||
@@ -10,6 +11,8 @@ export async function GET() {
|
||||
return NextResponse.json({ success: false}, { status: 500})
|
||||
}
|
||||
}
|
||||
|
||||
// @wikiDescription: Lied in einem Liederbuch erstellen
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const { title, songbookId, number } = await request.json();
|
||||
|
||||
@@ -8,10 +8,12 @@ let currentSong = {
|
||||
title: ""
|
||||
};
|
||||
|
||||
// @wikiDescription: Akutell gestreamtes Lied abrufen
|
||||
export async function GET() {
|
||||
return NextResponse.json(currentSong)
|
||||
}
|
||||
|
||||
// @wikiDescription: Lied zum Streamen festlegen
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const data = await request.json();
|
||||
|
||||
+28
-35
@@ -1,41 +1,34 @@
|
||||
import Article from "@/components/wiki/Article";
|
||||
import { API, Callout } from "@/components/mdx-components"
|
||||
import { getAllApis } from "@/lib/wiki";
|
||||
import Article from '@/components/wiki/Article';
|
||||
import { API } from '@/components/mdx-components';
|
||||
|
||||
export default async function Page() {
|
||||
const allApis = await getAllApis();
|
||||
|
||||
// Gruppiert die APIs nach ihrer Kategorie
|
||||
const groupedApis = Object.groupBy(allApis, (api) => api.category);
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<Article title="API-Endpunkte">
|
||||
<Callout type="info">
|
||||
Es ist weder eine Authentifikation noch ein API-Key erforderlich.
|
||||
</Callout>
|
||||
|
||||
<h2>Stream</h2>
|
||||
{Object.entries(groupedApis).map(([category, apis]) => (
|
||||
<div key={category} className="mb-10">
|
||||
{/* Kategorie-Überschrift wird nur EINMAL pro Kategorie gerendert */}
|
||||
<h2 className="text-2xl font-bold text-white mt-10 mb-4 border-b border-zinc-800 pb-2">
|
||||
{category}
|
||||
</h2>
|
||||
|
||||
<API method="GET" route="stream/currentID">
|
||||
Jetziges angezeigtes Lied abrufen
|
||||
</API>
|
||||
<API method="POST" route="stream/currentID">
|
||||
Lied zum Anzeigen festlegen
|
||||
</API>
|
||||
|
||||
<h2>Lieder</h2>
|
||||
|
||||
<API method="GET" route="songs/[id]">
|
||||
Informationen eines Liedes abrufen
|
||||
</API>
|
||||
<API method="POST" route="songs/attach">
|
||||
Lied zu einem Liederbuch hinzufügen
|
||||
</API>
|
||||
<API method="POST" route="songs/attach">
|
||||
Lied von einem Liederbuch entfernen
|
||||
</API>
|
||||
|
||||
<h2>Liederbücher</h2>
|
||||
<API method="GET" route="songbooks">
|
||||
Liste aller Liederbücher abrufen
|
||||
</API>
|
||||
<API method="POST" route="songbooks">
|
||||
Neues Liederbuch erstellen
|
||||
</API>
|
||||
{/* Routen innerhalb dieser Kategorie durchgehen */}
|
||||
{apis?.map((api, index) => (
|
||||
<div key={index} className="my-4">
|
||||
{api.methods.map((method, mIndex) => (
|
||||
<API route={api.route} method={method.method} key={mIndex}>
|
||||
{method.description}
|
||||
</API>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</Article>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user