Merge branch 'main' into add-qbittorrent

This commit is contained in:
Jason Fischer 2022-09-16 23:19:24 -07:00
commit 6c01a85077
No known key found for this signature in database
4 changed files with 45 additions and 3 deletions

View file

@ -2,7 +2,7 @@ import getServiceWidget from "utils/service-helpers";
import { formatApiCall } from "utils/api-helpers";
import { httpProxy } from "utils/http";
export default async function genericProxyHandler(req, res) {
export default async function genericProxyHandler(req, res, maps) {
const { group, service, endpoint } = req.query;
if (group && service) {
@ -23,13 +23,18 @@ export default async function genericProxyHandler(req, res) {
headers,
});
let resultData = data;
if (maps?.[endpoint]) {
resultData = maps[endpoint](data);
}
if (contentType) res.setHeader("Content-Type", contentType);
if (status === 204 || status === 304) {
return res.status(status).end();
}
return res.status(status).send(data);
return res.status(status).send(resultData);
}
}