mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-05 12:26:41 +02:00
feat: API now allows you to set the so you can control who can interact with the API.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import cors from "cors";
|
||||
import { BrowserWindow, dialog } from "electron";
|
||||
import express from "express";
|
||||
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";
|
||||
@@ -9,12 +8,14 @@ import { addCurrentInfo } from "./features/current";
|
||||
import { addPlaybackControl } from "./features/player";
|
||||
import { addSettingsAPI } from "./features/settings/settings";
|
||||
import { addLegacyApi } from "./legacy";
|
||||
import swaggerSpec from "./swagger.json";
|
||||
|
||||
/**
|
||||
* Function to enable TIDAL Hi-Fi's express api
|
||||
*/
|
||||
export const startApi = (mainWindow: BrowserWindow) => {
|
||||
const port = settingsStore.get<string, number>(settings.apiSettings.port);
|
||||
const hostname = settingsStore.get<string, string>(settings.apiSettings.hostname) ?? "127.0.0.1";
|
||||
|
||||
const expressApp = express();
|
||||
expressApp.use(cors());
|
||||
@@ -29,7 +30,7 @@ export const startApi = (mainWindow: BrowserWindow) => {
|
||||
addCurrentInfo(expressApp);
|
||||
addSettingsAPI(expressApp, mainWindow);
|
||||
|
||||
const expressInstance = expressApp.listen(port, "127.0.0.1");
|
||||
const expressInstance = expressApp.listen(port, hostname);
|
||||
expressInstance.on("error", function (e: { code: string }) {
|
||||
let message = e.code;
|
||||
if (e.code === "EADDRINUSE") {
|
||||
|
Reference in New Issue
Block a user