2022-09-04 21:58:42 +03:00
|
|
|
const formats = {
|
|
|
|
emby: `{url}/emby/{endpoint}?api_key={key}`,
|
2022-09-05 08:19:50 +03:00
|
|
|
jellyfin: `{url}/emby/{endpoint}?api_key={key}`,
|
2022-09-04 21:58:42 +03:00
|
|
|
pihole: `{url}/admin/{endpoint}`,
|
|
|
|
radarr: `{url}/api/v3/{endpoint}?apikey={key}`,
|
|
|
|
sonarr: `{url}/api/v3/{endpoint}?apikey={key}`,
|
|
|
|
speedtest: `{url}/api/{endpoint}`,
|
|
|
|
tautulli: `{url}/api/v2?apikey={key}&cmd={endpoint}`,
|
|
|
|
traefik: `{url}/api/{endpoint}`,
|
|
|
|
portainer: `{url}/api/endpoints/{env}/{endpoint}`,
|
|
|
|
rutorrent: `{url}/plugins/httprpc/action.php`,
|
|
|
|
jellyseerr: `{url}/api/v1/{endpoint}`,
|
|
|
|
ombi: `{url}/api/v1/{endpoint}`,
|
|
|
|
npm: `{url}/api/{endpoint}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
export function formatApiCall(api, args) {
|
|
|
|
const match = /\{.*?\}/g;
|
|
|
|
const replace = (match) => {
|
|
|
|
const key = match.replace(/\{|\}/g, "");
|
|
|
|
return args[key];
|
|
|
|
};
|
|
|
|
|
|
|
|
return formats[api].replace(match, replace);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function formatApiUrl(widget, endpoint) {
|
|
|
|
const params = new URLSearchParams({
|
|
|
|
type: widget.type,
|
|
|
|
group: widget.service_group,
|
|
|
|
service: widget.service_name,
|
|
|
|
endpoint,
|
|
|
|
});
|
|
|
|
return `/api/services/proxy?${params.toString()}`;
|
|
|
|
}
|