From aac573a48d2536ded87d8c6abed75233adc4e215 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:57:35 -0700 Subject: [PATCH] =?UTF-8?q?Enhancement:=20npm=20widget=20support=20?= =?UTF-8?q?=E2=89=A5=20v2.12=20(#4140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widgets/npm/component.jsx | 4 ++-- src/widgets/npm/proxy.js | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/widgets/npm/component.jsx b/src/widgets/npm/component.jsx index 06ac91ebe..e9f7e871f 100644 --- a/src/widgets/npm/component.jsx +++ b/src/widgets/npm/component.jsx @@ -21,8 +21,8 @@ export default function Component({ service }) { ); } - const enabled = infoData.filter((c) => c.enabled === 1).length; - const disabled = infoData.filter((c) => c.enabled === 0).length; + const enabled = infoData.filter((c) => !!c.enabled).length; + const disabled = infoData.filter((c) => !c.enabled).length; const total = infoData.length; return ( diff --git a/src/widgets/npm/proxy.js b/src/widgets/npm/proxy.js index 92a0140bf..3f1e34950 100644 --- a/src/widgets/npm/proxy.js +++ b/src/widgets/npm/proxy.js @@ -30,7 +30,7 @@ async function login(loginUrl, username, password, service) { cache.put(`${tokenCacheKey}.${service}`, data.token, expiration - 5 * 60 * 1000); // expiration -5 minutes } } catch (e) { - logger.error(`Error ${status} logging into npm`, authResponse[2]); + logger.error(`Error ${status} logging into npm`, JSON.stringify(authResponse[2])); } return [status, data.token ?? data]; } @@ -50,7 +50,6 @@ export default async function npmProxyHandler(req, res) { const loginUrl = `${widget.url}/api/tokens`; let status; - let contentType; let data; let token = cache.get(`${tokenCacheKey}.${service}`); @@ -62,7 +61,7 @@ export default async function npmProxyHandler(req, res) { } } - [status, contentType, data] = await httpProxy(url, { + [status, , data] = await httpProxy(url, { method: "GET", headers: { "Content-Type": "application/json", @@ -81,7 +80,7 @@ export default async function npmProxyHandler(req, res) { } // eslint-disable-next-line no-unused-vars - [status, contentType, data] = await httpProxy(url, { + [status, , data] = await httpProxy(url, { method: "GET", headers: { "Content-Type": "application/json",