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

@ -27,25 +27,24 @@ export default function Component({ service }) {
return (
<Container service={service}>
<Block
label="widget.status"
value={t(`homebridge.${homebridgeData.status}`)}
/>
<Block label="widget.status" value={t(`homebridge.${homebridgeData.status}`)} />
<Block
label="homebridge.updates"
value={
(homebridgeData.updateAvailable || homebridgeData.plugins?.updatesAvailable)
homebridgeData.updateAvailable || homebridgeData.plugins?.updatesAvailable
? t("homebridge.update_available")
: t("homebridge.up_to_date")}
: t("homebridge.up_to_date")
}
/>
{homebridgeData?.childBridges?.total > 0 &&
{homebridgeData?.childBridges?.total > 0 && (
<Block
label="homebridge.child_bridges"
value={t("homebridge.child_bridges_status", {
total: homebridgeData.childBridges.total,
ok: homebridgeData.childBridges.running
ok: homebridgeData.childBridges.running,
})}
/>}
/>
)}
</Container>
);
}

View file

@ -12,7 +12,7 @@ const logger = createLogger(proxyName);
async function login(widget, service) {
const endpoint = "auth/login";
const api = widgets?.[widget.type]?.api
const api = widgets?.[widget.type]?.api;
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
const loginBody = { username: widget.username, password: widget.password };
const headers = { "Content-Type": "application/json" };
@ -25,8 +25,8 @@ async function login(widget, service) {
try {
const { access_token: accessToken, expires_in: expiresIn } = JSON.parse(data.toString());
cache.put(`${sessionTokenCacheKey}.${service}`, accessToken, (expiresIn * 1000) - 5 * 60 * 1000); // expiresIn (s) - 5m
cache.put(`${sessionTokenCacheKey}.${service}`, accessToken, expiresIn * 1000 - 5 * 60 * 1000); // expiresIn (s) - 5m
return { accessToken };
} catch (e) {
logger.error("Unable to login to Homebridge API: %s", e);
@ -39,8 +39,8 @@ async function apiCall(widget, endpoint, service) {
const key = `${sessionTokenCacheKey}.${service}`;
const headers = {
"content-type": "application/json",
"Authorization": `Bearer ${cache.get(key)}`,
}
Authorization: `Bearer ${cache.get(key)}`,
};
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
const method = "GET";
@ -95,14 +95,14 @@ export default async function homebridgeProxyHandler(req, res) {
const { data: pluginsData } = await apiCall(widget, "plugins", service);
return res.status(200).send({
status: statusData?.status,
updateAvailable: versionData?.updateAvailable,
plugins: {
updatesAvailable: pluginsData?.filter(p => p.updateAvailable).length,
},
childBridges: {
running: childBridgeData?.filter(cb => cb.status === "ok").length,
total: childBridgeData?.length
}
status: statusData?.status,
updateAvailable: versionData?.updateAvailable,
plugins: {
updatesAvailable: pluginsData?.filter((p) => p.updateAvailable).length,
},
childBridges: {
running: childBridgeData?.filter((cb) => cb.status === "ok").length,
total: childBridgeData?.length,
},
});
}

View file

@ -7,7 +7,7 @@ const widget = {
mappings: {
info: {
endpoint: "/",
}
},
},
};