Update API Doc
This commit is contained in:
1 parent
5d6d8f15f3
commit
5a56245218
10 files changed
+1196
-229
No files matched your search
+97
-3
@@ -1,7 +1,22 @@
|
||||
// @wikiCategory: Stream
|
||||
// @/app/api/stream/route.ts
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* components:
|
||||
* schemas:
|
||||
* StreamError:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* example: false
|
||||
* error:
|
||||
* type: string
|
||||
* example: "Fields incomplete!"
|
||||
*/
|
||||
|
||||
|
||||
let currentSong = {
|
||||
number: "",
|
||||
@@ -11,7 +26,23 @@ let currentSong = {
|
||||
const clients = new Set<ReadableStreamDefaultController>();
|
||||
|
||||
|
||||
// @wikiDescription: Akutell gestreamtes Lied abrufen
|
||||
/**
|
||||
* @openapi
|
||||
* /api/stream:
|
||||
* get:
|
||||
* summary: Aktuell gestreamtes Lied abrufen (Server-Sent Events)
|
||||
* description: Öffnet einen SSE-Stream. Beim Verbinden wird das aktuelle Lied gesendet (falls gesetzt), danach bei jeder Änderung ein neues Event.
|
||||
* tags:
|
||||
* - Stream
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Event-Stream mit dem aktuellen Lied
|
||||
* content:
|
||||
* text/event-stream:
|
||||
* schema:
|
||||
* type: string
|
||||
* example: 'data: {"number":"104a","song":"Großer Gott","songbook":"Feiert Jesus 1"}'
|
||||
*/
|
||||
export async function GET() {
|
||||
let controllerRef: ReadableStreamDefaultController;
|
||||
|
||||
@@ -38,7 +69,70 @@ export async function GET() {
|
||||
});
|
||||
}
|
||||
|
||||
// @wikiDescription: Lied zum Streamen festlegen
|
||||
/**
|
||||
* @openapi
|
||||
* /api/stream:
|
||||
* post:
|
||||
* summary: Lied zum Streamen festlegen
|
||||
* description: Setzt das aktuelle Lied und sendet es an alle verbundenen Stream-Clients.
|
||||
* tags:
|
||||
* - Stream
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - song
|
||||
* - songBook
|
||||
* - number
|
||||
* properties:
|
||||
* song:
|
||||
* type: string
|
||||
* example: "Großer Gott"
|
||||
* songBook:
|
||||
* type: string
|
||||
* example: "Feiert Jesus 1"
|
||||
* number:
|
||||
* type: string
|
||||
* example: "104a"
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Lied gesetzt und an alle Clients gesendet
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* example: true
|
||||
* currentSong:
|
||||
* type: object
|
||||
* properties:
|
||||
* number:
|
||||
* type: string
|
||||
* example: "104a"
|
||||
* song:
|
||||
* type: string
|
||||
* example: "Großer Gott"
|
||||
* songbook:
|
||||
* type: string
|
||||
* example: "Feiert Jesus 1"
|
||||
* 400:
|
||||
* description: Felder unvollständig
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/StreamError'
|
||||
* 500:
|
||||
* description: Serverfehler
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/StreamError'
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const data = await request.json();
|
||||
|
||||
Reference in new issue
Block a user