From 84acccba83ba224fe2c129a21aa1d8928151514a Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Tue, 6 Jun 2023 18:30:00 +0100 Subject: [PATCH 1/2] linting fixes --- src/widgets/jdrssdownloader/proxy.js | 12 ++++++------ src/widgets/wgeasy/proxy.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/widgets/jdrssdownloader/proxy.js b/src/widgets/jdrssdownloader/proxy.js index 99452692..71c2a945 100644 --- a/src/widgets/jdrssdownloader/proxy.js +++ b/src/widgets/jdrssdownloader/proxy.js @@ -65,7 +65,7 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let showCount; + let showCount = 0; showCount = apiData.length; // Calculate the number of items in the retry cache @@ -73,7 +73,7 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let retryCache; + let retryCache = 0; retryCache = apiData.length; // Calculate the number of items in the feed cache @@ -81,13 +81,13 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let feedCache; + let feedCache = 0; feedCache = apiData.length; const data = { - showCount:showCount, - retryCache:retryCache, - feedCache:feedCache + showCount, + retryCache, + feedCache }; diff --git a/src/widgets/wgeasy/proxy.js b/src/widgets/wgeasy/proxy.js index 233e80da..40ddd792 100644 --- a/src/widgets/wgeasy/proxy.js +++ b/src/widgets/wgeasy/proxy.js @@ -33,9 +33,9 @@ async function loginToWGEasy(endpoint, widget) { return [403, null]; } // Create new session on WgEasy - let url = new URL(formatApiCall(api, { endpoint, ...widget })); + const url = new URL(formatApiCall(api, { endpoint, ...widget })); - let [status, contentType, data, responseHeaders] = await httpProxy(url, { + const [status, data, , responseHeaders] = await httpProxy(url, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -50,7 +50,7 @@ async function loginToWGEasy(endpoint, widget) { return [status, data, responseHeaders]; } try { - globalSid = responseHeaders["set-cookie"][0] + [ globalSid ] = responseHeaders["set-cookie"] } catch (e) { logger.error("Error decoding NextPVR API data. Data: %s", data.toString()); return [status, null]; @@ -99,14 +99,14 @@ export default async function WGeasyProxyHandler(req, res) { logger.debug("Getting data from WGeasy API"); // Calculate the number of clients - let [status, apiData] = await fetchDataFromWGeasy('wireguard/client', widget, globalSid); + const [status, apiData] = await fetchDataFromWGeasy('wireguard/client', widget, globalSid); if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let clientCount; + let clientCount = 0; clientCount = apiData.length; - + const data = { clientCount }; From b26e07cf26d0c43b102579d144c4949fb9ebc025 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Wed, 7 Jun 2023 08:54:24 +0100 Subject: [PATCH 2/2] linting fixes --- src/widgets/wgeasy/proxy.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/widgets/wgeasy/proxy.js b/src/widgets/wgeasy/proxy.js index 233e80da..76f61151 100644 --- a/src/widgets/wgeasy/proxy.js +++ b/src/widgets/wgeasy/proxy.js @@ -33,9 +33,9 @@ async function loginToWGEasy(endpoint, widget) { return [403, null]; } // Create new session on WgEasy - let url = new URL(formatApiCall(api, { endpoint, ...widget })); + const url = new URL(formatApiCall(api, { endpoint, ...widget })); - let [status, contentType, data, responseHeaders] = await httpProxy(url, { + const [status, data, , responseHeaders] = await httpProxy(url, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -50,7 +50,7 @@ async function loginToWGEasy(endpoint, widget) { return [status, data, responseHeaders]; } try { - globalSid = responseHeaders["set-cookie"][0] + [ globalSid ] = responseHeaders["set-cookie"] } catch (e) { logger.error("Error decoding NextPVR API data. Data: %s", data.toString()); return [status, null]; @@ -99,14 +99,14 @@ export default async function WGeasyProxyHandler(req, res) { logger.debug("Getting data from WGeasy API"); // Calculate the number of clients - let [status, apiData] = await fetchDataFromWGeasy('wireguard/client', widget, globalSid); + const [status, apiData] = await fetchDataFromWGeasy('wireguard/client', widget, globalSid); if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let clientCount; + let clientCount = 0; clientCount = apiData.length; - + const data = { clientCount }; @@ -115,4 +115,3 @@ export default async function WGeasyProxyHandler(req, res) { } -