diff --git a/src/api/web/endpoint/package.js b/src/api/web/endpoint/package.js index 3f3a333f4..09c9d2efd 100644 --- a/src/api/web/endpoint/package.js +++ b/src/api/web/endpoint/package.js @@ -7,6 +7,7 @@ import _ from 'lodash'; import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils'; import { allow } from '../../middleware'; import { DIST_TAGS, HEADER_TYPE, HEADERS, HTTP_STATUS } from '../../../lib/constants'; +import logger from '../../../lib/logger'; import type { Router } from 'express'; import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types'; import type { Config } from '@verdaccio/types'; @@ -44,6 +45,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; } } diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 679a2d2f4..276bb4e36 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -642,7 +642,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) { diff --git a/src/lib/storage.js b/src/lib/storage.js index 778d10c53..81b50b924 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -322,17 +322,20 @@ class Storage implements IStorageHandler { ); 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 @@ -411,7 +414,7 @@ class Storage implements IStorageHandler { const upLinks = []; const hasToLookIntoUplinks = _.isNil(options.uplinksLook) || options.uplinksLook; - 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 20b227a5e..d568d3682 100644 --- a/src/lib/up-storage.js +++ b/src/lib/up-storage.js @@ -145,7 +145,7 @@ class ProxyStorage implements IProxy { let error; const responseLength = err ? 0 : body.length; // $FlowFixMe - processBody(err, body); + processBody(); logActivity(); // $FlowFixMe cb(err, res, body); @@ -552,7 +552,7 @@ class ProxyStorage implements IProxy { // https://github.com/rlidwka/sinopia/issues/254 // if (this.proxy === false) { - headers['X-Forwarded-For'] = (req && req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] + ', ' : '') + req.connection.remoteAddress; + headers['X-Forwarded-For'] = (req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] + ', ' : '') + req.connection.remoteAddress; } } diff --git a/src/utils/user.js b/src/utils/user.js index 9369a20f0..e9a4f41c5 100644 --- a/src/utils/user.js +++ b/src/utils/user.js @@ -34,11 +34,10 @@ export const GENERIC_AVATAR: string = ` * Generate gravatar url from email address */ export function generateGravatarUrl(email: string = '', online: boolean = true): string { - let emailCopy = email; if (online) { 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 GENERIC_AVATAR;