|
|
|
@ -22,32 +22,22 @@ export default async function tdarrProxyHandler(req, res) {
|
|
|
|
|
return res.status(400).json({ error: "Invalid proxy service type" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
|
|
|
|
|
|
|
|
|
const method = "POST";
|
|
|
|
|
|
|
|
|
|
const headers = {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const body = JSON.stringify({
|
|
|
|
|
const [status, contentType, data] = await httpProxy(url, {
|
|
|
|
|
method: "POST",
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
"data": {
|
|
|
|
|
"collection": "StatisticsJSONDB",
|
|
|
|
|
"mode": "getById",
|
|
|
|
|
"docID": "statistics"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
|
|
|
|
|
method,
|
|
|
|
|
body,
|
|
|
|
|
headers,
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
headers: {
|
|
|
|
|
"content-type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (status !== 200) {
|
|
|
|
|
logger.error("Error getting data from Tdarr: %d. Data: %s", status, data);
|
|
|
|
|
return res.status(500).send({error: {message:"Error getting data from Tdarr", url, data}});
|
|
|
|
|