mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-10 02:12:09 +08:00
Add Winston for log handling
- write log data to 'homepage.log'
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import getServiceWidget from "utils/service-helpers";
|
||||
import { formatApiCall } from "utils/api-helpers";
|
||||
import { httpProxy } from "utils/http";
|
||||
import logger from "utils/logger";
|
||||
|
||||
export default async function genericProxyHandler(req, res, maps) {
|
||||
const { group, service, endpoint } = req.query;
|
||||
@@ -24,7 +25,7 @@ export default async function genericProxyHandler(req, res, maps) {
|
||||
});
|
||||
|
||||
let resultData = data;
|
||||
if (maps?.[endpoint]) {
|
||||
if ((status === 200) && (maps?.[endpoint])) {
|
||||
resultData = maps[endpoint](data);
|
||||
}
|
||||
|
||||
@@ -34,9 +35,14 @@ export default async function genericProxyHandler(req, res, maps) {
|
||||
return res.status(status).end();
|
||||
}
|
||||
|
||||
if (status >= 400) {
|
||||
logger.debug("HTTP Error %d calling %s//%s%s...", status, url.protocol, url.hostname, url.pathname);
|
||||
}
|
||||
|
||||
return res.status(status).send(resultData);
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Invalid or missing proxy service type '%s' in group '%s'", service, group);
|
||||
return res.status(400).json({ error: "Invalid proxy service type" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user