You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1020 B
35 lines
1020 B
2 years ago
|
const formats = {
|
||
|
emby: `{url}/emby/{endpoint}?api_key={key}`,
|
||
|
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()}`;
|
||
|
}
|