From e9b3907859f8ded39bf22e8fbf47040771215513 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Mon, 14 Jan 2019 19:19:56 +0100 Subject: [PATCH 1/6] fix: remove unused object (#1185) Remove unused object --- src/lib/local-storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 323b93bdd..ffbc5d8a0 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -641,7 +641,7 @@ class LocalStorage implements IStorage { const {packages} = this.config; if (packages) { - const listPackagesConf = Object.keys(packages || {}); + const listPackagesConf = Object.keys(packages); listPackagesConf.map( (pkg) => { if (packages[pkg].storage) { From f20fefaf8732b1dbad81b106faba6da42279ead7 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Mon, 14 Jan 2019 19:25:29 +0100 Subject: [PATCH 2/6] fix: remove use of comma separator (#1186) --- src/lib/storage.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/storage.js b/src/lib/storage.js index fdbe3b6ac..e0d7ac091 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -324,17 +324,20 @@ class Storage implements IStorageHandler { lstream.pipe(stream, {end: false}); lstream.on('error', function(err) { self.logger.error({err: err}, 'uplink error: @{err.message}'); - cb(), cb = function() {}; + cb(); + cb = function() {}; }); lstream.on('end', function() { - cb(), cb = function() {}; + cb(); + cb = function() {}; }); stream.abort = function() { if (lstream.abort) { lstream.abort(); } - cb(), cb = function() {}; + cb(); + cb = function() {}; }; }, // executed after all series From 064f7cfa5d3a0c66d956ed06561458f88c22e2ef Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Mon, 14 Jan 2019 19:34:03 +0100 Subject: [PATCH 3/6] fix: remove unused parameters from processBody method invocation (#1184) --- src/lib/up-storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/up-storage.js b/src/lib/up-storage.js index 3fea3d657..c011698de 100644 --- a/src/lib/up-storage.js +++ b/src/lib/up-storage.js @@ -141,7 +141,7 @@ class ProxyStorage implements IProxy { let error; const responseLength = err ? 0 : body.length; // $FlowFixMe - processBody(err, body); + processBody(); logActivity(); // $FlowFixMe cb(err, res, body); From ab56d750cac0caac54a7b3d6f7c2cd8c1b3be382 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Mon, 14 Jan 2019 19:39:59 +0100 Subject: [PATCH 4/6] fix: remove some unneeded checks (#1182) --- src/lib/storage.js | 2 +- src/lib/up-storage.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/storage.js b/src/lib/storage.js index e0d7ac091..e13ac4290 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -411,7 +411,7 @@ class Storage implements IStorageHandler { const self = this; const upLinks = []; - if (!packageInfo || packageInfo === null) { + if (!packageInfo) { exists = false; packageInfo = generatePackageTemplate(name); } diff --git a/src/lib/up-storage.js b/src/lib/up-storage.js index c011698de..efd503781 100644 --- a/src/lib/up-storage.js +++ b/src/lib/up-storage.js @@ -540,7 +540,7 @@ class ProxyStorage implements IProxy { // if (this.proxy === false) { headers['X-Forwarded-For'] = ( - req && req.headers['x-forwarded-for'] + req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] + ', ' : '' ) + req.connection.remoteAddress; From 13b8347fdd65df8754cad18c0ec0734471a29c70 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Mon, 14 Jan 2019 20:52:04 +0100 Subject: [PATCH 5/6] fix: remove useless assignment to local variable emailCopy (#1181) --- src/utils/user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/user.js b/src/utils/user.js index 1a751ba85..e7ea03d8d 100644 --- a/src/utils/user.js +++ b/src/utils/user.js @@ -8,10 +8,9 @@ export const GRAVATAR_DEFAULT = * Generate gravatar url from email address */ export function generateGravatarUrl(email: string = ''): string { - let emailCopy = email; if (_.isString(email) && _.size(email) > 0) { - emailCopy = email.trim().toLocaleLowerCase(); - const emailMD5 = stringToMD5(emailCopy); + email = email.trim().toLocaleLowerCase(); + const emailMD5 = stringToMD5(email); return `https://www.gravatar.com/avatar/${emailMD5}`; } return GRAVATAR_DEFAULT; From 056d396b59b3f17553e28163445129c3e275b652 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Tue, 15 Jan 2019 09:29:04 +0100 Subject: [PATCH 6/6] fix: add logic to catch clause (#1183) --- src/api/web/endpoint/package.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/api/web/endpoint/package.js b/src/api/web/endpoint/package.js index 5ab515eb8..e1d024588 100644 --- a/src/api/web/endpoint/package.js +++ b/src/api/web/endpoint/package.js @@ -3,6 +3,7 @@ import _ from 'lodash'; import {addScope, addGravatarSupport, deleteProperties, sortByName, DIST_TAGS, parseReadme} from '../../../lib/utils'; import {allow} from '../../middleware'; +import logger from '../../../lib/logger'; import type {Router} from 'express'; import type { IAuth, @@ -45,6 +46,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth) permissions.push(pkg); } } catch (err) { + logger.logger.error({name: pkg.name, error: err}, 'permission process for @{name} has failed: @{error}'); throw err; } }