Enhancement: npm widget support ≥ v2.12 (#4140)

This commit is contained in:
shamoon 2024-10-16 07:57:35 -07:00 committed by GitHub
parent cf9109384e
commit aac573a48d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -21,8 +21,8 @@ export default function Component({ service }) {
); );
} }
const enabled = infoData.filter((c) => c.enabled === 1).length; const enabled = infoData.filter((c) => !!c.enabled).length;
const disabled = infoData.filter((c) => c.enabled === 0).length; const disabled = infoData.filter((c) => !c.enabled).length;
const total = infoData.length; const total = infoData.length;
return ( return (

View File

@ -30,7 +30,7 @@ async function login(loginUrl, username, password, service) {
cache.put(`${tokenCacheKey}.${service}`, data.token, expiration - 5 * 60 * 1000); // expiration -5 minutes cache.put(`${tokenCacheKey}.${service}`, data.token, expiration - 5 * 60 * 1000); // expiration -5 minutes
} }
} catch (e) { } 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]; return [status, data.token ?? data];
} }
@ -50,7 +50,6 @@ export default async function npmProxyHandler(req, res) {
const loginUrl = `${widget.url}/api/tokens`; const loginUrl = `${widget.url}/api/tokens`;
let status; let status;
let contentType;
let data; let data;
let token = cache.get(`${tokenCacheKey}.${service}`); 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", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -81,7 +80,7 @@ export default async function npmProxyHandler(req, res) {
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
[status, contentType, data] = await httpProxy(url, { [status, , data] = await httpProxy(url, {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",