mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
Merge branch 'main' into add-qbittorrent
This commit is contained in:
commit
6c01a85077
4 changed files with 45 additions and 3 deletions
|
@ -6,6 +6,16 @@ import npmProxyHandler from "utils/proxies/npm";
|
|||
import transmissionProxyHandler from "utils/proxies/transmission";
|
||||
import qbittorrentProxyHandler from "utils/proxies/qbittorrent";
|
||||
|
||||
function jsonArrayMapper(data, map) {
|
||||
if (data?.length > 0) {
|
||||
const json = JSON.parse(data.toString());
|
||||
if (json instanceof Array) {
|
||||
return json.map(map);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
const serviceProxyHandlers = {
|
||||
// uses query param auth
|
||||
emby: genericProxyHandler,
|
||||
|
@ -44,7 +54,14 @@ export default async function handler(req, res) {
|
|||
const serviceProxyHandler = serviceProxyHandlers[type];
|
||||
|
||||
if (serviceProxyHandler) {
|
||||
return serviceProxyHandler(req, res);
|
||||
if (serviceProxyHandler instanceof Function) {
|
||||
return serviceProxyHandler(req, res);
|
||||
}
|
||||
|
||||
const { proxy, maps } = serviceProxyHandler;
|
||||
if (proxy) {
|
||||
return proxy(req, res, maps);
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(403).json({ error: "Unkown proxy service type" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue