mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
refactor: improve readability
This commit is contained in:
parent
02d910149b
commit
cbc6479003
4 changed files with 9 additions and 21 deletions
|
@ -20,11 +20,11 @@ export function allow_action(action) {
|
|||
|
||||
export function getDefaultPlugins() {
|
||||
return {
|
||||
authenticate: function(user, password, cb) {
|
||||
authenticate(user, password, cb) {
|
||||
cb(ErrorCode.getForbidden(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||
},
|
||||
|
||||
add_user: function(user, password, cb) {
|
||||
add_user(user, password, cb) {
|
||||
return cb(ErrorCode.getConflict(API_ERROR.BAD_USERNAME_PASSWORD));
|
||||
},
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export function normalizeUserlist(oldFormat: any, newFormat: any) {
|
|||
}
|
||||
|
||||
// if it's a string, split it to array
|
||||
if (typeof(arguments[i]) === 'string') {
|
||||
if (_.isString(arguments[i])) {
|
||||
result.push(arguments[i].split(/\s+/));
|
||||
} else if (Array.isArray(arguments[i])) {
|
||||
result.push(arguments[i]);
|
||||
|
@ -60,7 +60,7 @@ export function uplinkSanityCheck(uplinks: UpLinksConfList, users: any = BLACKLI
|
|||
export function sanityCheckNames(item: string, users: any) {
|
||||
assert(item !== 'all' && item !== 'owner' && item !== 'anonymous' && item !== 'undefined' && item !== 'none', 'CONFIG: reserved uplink name: ' + item);
|
||||
assert(!item.match(/\s/), 'CONFIG: invalid uplink name: ' + item);
|
||||
assert(users[item] == null, 'CONFIG: duplicate uplink name: ' + item);
|
||||
assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);
|
||||
users[item] = true;
|
||||
|
||||
return users;
|
||||
|
@ -87,12 +87,7 @@ export function hasProxyTo(pkg: string, upLink: string, packages: PackageList):
|
|||
const matchedPkg: MatchedPackage = (getMatchedPackagesSpec(pkg, packages): MatchedPackage);
|
||||
const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];
|
||||
if (proxyList) {
|
||||
return proxyList.reduce((prev, curr) => {
|
||||
if (upLink === curr) {
|
||||
return true;
|
||||
}
|
||||
return prev;
|
||||
}, false);
|
||||
return proxyList.some((curr) => upLink === curr);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -78,11 +78,11 @@ class Config implements AppConfig {
|
|||
this.packages = normalisePackageAccess(self.packages);
|
||||
|
||||
// loading these from ENV if aren't in config
|
||||
allowedEnvConfig.forEach((function(v) {
|
||||
if (!(v in self)) {
|
||||
self[v] = process.env[v] || process.env[v.toUpperCase()];
|
||||
allowedEnvConfig.forEach((envConf) => {
|
||||
if (!(envConf in self)) {
|
||||
self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
// unique identifier of self server (or a cluster), used to avoid loops
|
||||
if (!this.server_id) {
|
||||
|
|
|
@ -96,13 +96,6 @@ export interface IStorageHandler {
|
|||
_updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy): void;
|
||||
}
|
||||
|
||||
// export interface ConfigHandler {
|
||||
// checkSecretKey(token: string): string;
|
||||
// hasProxyTo(pkg: string, upLink: string): boolean;
|
||||
// getMatchedPackagesSpec(storage: string): verdaccio$PackageAccess | void;
|
||||
// [key: string]: number;
|
||||
// }
|
||||
|
||||
export type StartUpConfig = {
|
||||
storage: string;
|
||||
self_path: string;
|
||||
|
|
Loading…
Add table
Reference in a new issue