import axios, { AxiosResponse } from 'axios'; import { PortInfo, Settings } from 'ontime-types'; import { apiEntryUrl } from './constants'; import type { RequestOptions } from './requestOptions'; const settingsPath = `${apiEntryUrl}/settings`; /** * HTTP request to retrieve application settings */ export async function getSettings(options?: RequestOptions): Promise { const res = await axios.get(settingsPath, { signal: options?.signal }); return res.data; } /** * HTTP request to mutate application settings */ export async function postSettings(data: Settings): Promise> { return axios.post(settingsPath, data); } /** * Allows setting the welcome modal dialog state from the clients */ export async function postShowWelcomeDialog(show: boolean) { axios.post(`${settingsPath}/welcomedialog`, { show }); } /** * HTTP request to retrieve server port */ export async function getServerPort(options?: RequestOptions): Promise { const res = await axios.get(`${settingsPath}/serverport`, { signal: options?.signal }); return res.data; } /** * HTTP request to set server port */ export async function postServerPort(serverPort: number): Promise> { return axios.post(`${settingsPath}/serverport`, { serverPort }); }