Run pre-commit hooks over existing codebase

Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
shamoon
2023-10-17 23:26:55 -07:00
parent fa50bbad9c
commit 19c25713c4
387 changed files with 4785 additions and 4109 deletions

View File

@@ -8,7 +8,7 @@ const proxyName = "watchtowerProxyHandler";
const logger = createLogger(proxyName);
export default async function watchtowerProxyHandler(req, res) {
const { group, service, endpoint } = req.query;
const { group, service, endpoint } = req.query;
if (!group || !service) {
logger.debug("Invalid or missing service '%s' or group '%s'", service, group);
@@ -22,27 +22,32 @@ export default async function watchtowerProxyHandler(req, res) {
return res.status(400).json({ error: "Invalid proxy service type" });
}
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
const [status, contentType, data] = await httpProxy(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${widget.key}`,
}
Authorization: `Bearer ${widget.key}`,
},
});
if (status !== 200 || !data) {
logger.error("Error getting data from WatchTower: %d. Data: %s", status, data);
return res.status(status).json({error: {message: `HTTP Error ${status}`, url, data}});
return res.status(status).json({ error: { message: `HTTP Error ${status}`, url, data } });
}
const cleanData = data.toString().split("\n").filter(s => s.startsWith("watchtower"));
const jsonRes = {}
cleanData.map(e => e.split(" ")).forEach(strArray => {
const [key, value] = strArray
jsonRes[key] = value
});
const cleanData = data
.toString()
.split("\n")
.filter((s) => s.startsWith("watchtower"));
const jsonRes = {};
cleanData
.map((e) => e.split(" "))
.forEach((strArray) => {
const [key, value] = strArray;
jsonRes[key] = value;
});
if (contentType) res.setHeader("Content-Type", contentType);
return res.status(status).send(jsonRes);