
- extract cookie jar functionality into its own file - use i18n for more strings in existing widgets completes: #152 associated: #123
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
const formats = {
|
|
emby: `{url}/emby/{endpoint}?api_key={key}`,
|
|
jellyfin: `{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`,
|
|
transmission: `{url}/transmission/rpc`,
|
|
qbittorrent: `{url}/api/v2/{endpoint}`,
|
|
jellyseerr: `{url}/api/v1/{endpoint}`,
|
|
overseerr: `{url}/api/v1/{endpoint}`,
|
|
ombi: `{url}/api/v1/{endpoint}`,
|
|
npm: `{url}/api/{endpoint}`,
|
|
lidarr: `{url}/api/v1/{endpoint}?apikey={key}`,
|
|
readarr: `{url}/api/v1/{endpoint}?apikey={key}`,
|
|
bazarr: `{url}/api/{endpoint}/wanted?apikey={key}`,
|
|
sabnzbd: `{url}/api/?apikey={key}&output=json&mode={endpoint}`,
|
|
coinmarketcap: `https://pro-api.coinmarketcap.com/{endpoint}`,
|
|
gotify: `{url}/{endpoint}`,
|
|
prowlarr: `{url}/api/v1/{endpoint}`,
|
|
jackett: `{url}/api/v2.0/{endpoint}?apikey={key}&configured=true`,
|
|
adguard: `{url}/control/{endpoint}`,
|
|
};
|
|
|
|
export function formatApiCall(api, args) {
|
|
const find = /\{.*?\}/g;
|
|
const replace = (match) => {
|
|
const key = match.replace(/\{|\}/g, "");
|
|
return args[key];
|
|
};
|
|
|
|
return formats[api].replace(find, 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()}`;
|
|
}
|