mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-07-27 16:12:29 +02:00
hotfix: fixed api not working due to swagger
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { BrowserWindow, dialog } from "electron";
|
||||
import express from "express";
|
||||
import swaggerjsdoc from "swagger-jsdoc";
|
||||
import swaggerSpec from "./swagger.json";
|
||||
import cors from "cors";
|
||||
import swaggerUi from "swagger-ui-express";
|
||||
import { settingsStore } from "../../scripts/settings";
|
||||
import { settings } from "./../../constants/settings";
|
||||
@@ -8,48 +9,19 @@ import { addCurrentInfo } from "./features/current";
|
||||
import { addPlaybackControl } from "./features/player";
|
||||
import { addSettingsAPI } from "./features/settings/settings";
|
||||
import { addLegacyApi } from "./legacy";
|
||||
import cors from "cors";
|
||||
|
||||
/**
|
||||
* Function to enable TIDAL Hi-Fi's express api
|
||||
*/
|
||||
export const startApi = (mainWindow: BrowserWindow) => {
|
||||
const port = settingsStore.get<string, number>(settings.apiSettings.port);
|
||||
const specs = swaggerjsdoc({
|
||||
definition: {
|
||||
openapi: "3.1.0",
|
||||
info: {
|
||||
title: "TIDAL Hi-Fi API",
|
||||
version: "5.13.0",
|
||||
description: "",
|
||||
license: {
|
||||
name: "MIT",
|
||||
url: "https://github.com/Mastermindzh/tidal-hifi/blob/master/LICENSE",
|
||||
},
|
||||
contact: {
|
||||
name: "Rick <mastermindzh> van Lieshout",
|
||||
url: "https://www.rickvanlieshout.com",
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: `http://localhost:${port}`,
|
||||
},
|
||||
],
|
||||
externalDocs: {
|
||||
description: "swagger.json",
|
||||
url: "swagger.json",
|
||||
},
|
||||
},
|
||||
apis: ["**/*.ts"],
|
||||
});
|
||||
|
||||
const expressApp = express();
|
||||
expressApp.use(cors());
|
||||
expressApp.use(express.json());
|
||||
expressApp.use("/docs", swaggerUi.serve, swaggerUi.setup(specs));
|
||||
expressApp.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
|
||||
expressApp.get("/", (req, res) => res.send("Hello World!"));
|
||||
expressApp.get("/swagger.json", (req, res) => res.json(specs));
|
||||
expressApp.get("/swagger.json", (req, res) => res.json(swaggerSpec));
|
||||
|
||||
// add features
|
||||
addLegacyApi(expressApp, mainWindow);
|
||||
|
135
src/features/api/swagger.json
Normal file
135
src/features/api/swagger.json
Normal file
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "TIDAL Hi-Fi API",
|
||||
"version": "5.13.1",
|
||||
"description": "",
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/Mastermindzh/tidal-hifi/blob/master/LICENSE"
|
||||
},
|
||||
"contact": {
|
||||
"name": "Rick <mastermindzh> van Lieshout",
|
||||
"url": "https://www.rickvanlieshout.com"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "http://localhost:47836"
|
||||
}
|
||||
],
|
||||
"externalDocs": {
|
||||
"description": "swagger.json",
|
||||
"url": "swagger.json"
|
||||
},
|
||||
"paths": {
|
||||
"/settings/skipped-artists": {
|
||||
"get": {
|
||||
"summary": "get a list of artists that TIDAL Hi-Fi will skip if skipping is enabled",
|
||||
"tags": [
|
||||
"settings"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The list book.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/StringArray"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Add new artists to the list of skipped artists",
|
||||
"tags": [
|
||||
"settings"
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/StringArray"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/skipped-artists/delete": {
|
||||
"post": {
|
||||
"summary": "Remove artists from the list of skipped artists",
|
||||
"tags": [
|
||||
"settings"
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/StringArray"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/skipped-artists/current": {
|
||||
"post": {
|
||||
"summary": "Add the current artist to the list of skipped artists",
|
||||
"tags": [
|
||||
"settings"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"summary": "Remove the current artist from the list of skipped artists",
|
||||
"tags": [
|
||||
"settings"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"StringArray": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": [
|
||||
"Artist1",
|
||||
"Artist2"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "settings",
|
||||
"description": "The settings management API"
|
||||
}
|
||||
]
|
||||
}
|
@@ -433,7 +433,7 @@
|
||||
<h4>TIDAL Hi-Fi</h4>
|
||||
<div class="about-section__version">
|
||||
<a target="_blank" rel="noopener"
|
||||
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.13.0">5.13.0</a>
|
||||
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.13.1">5.13.1</a>
|
||||
</div>
|
||||
<div class="about-section__links">
|
||||
<a target="_blank" rel="noopener" href="https://github.com/mastermindzh/tidal-hifi/"
|
||||
|
Reference in New Issue
Block a user