mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
refactor: private methods
This commit is contained in:
parent
a75b7bdcdd
commit
7617a51f6e
1 changed files with 27 additions and 23 deletions
|
@ -50,29 +50,7 @@ class LocalStorage implements IStorage {
|
|||
this.logger = logger.child({sub: 'fs'});
|
||||
this.config = config;
|
||||
this.localData = this._loadStorage(config, logger);
|
||||
config.secret = config.checkSecretKey(this.localData.getSecret());
|
||||
this.localData.setSecret(this.config.secret);
|
||||
}
|
||||
|
||||
_loadStorage(config: Config, logger: Logger) {
|
||||
const Storage = this._loadStorePlugin();
|
||||
|
||||
if (_.isNil(Storage)) {
|
||||
return new LocalDatabase(this.config, logger);
|
||||
} else {
|
||||
return Storage;
|
||||
}
|
||||
}
|
||||
|
||||
_loadStorePlugin() {
|
||||
const plugin_params = {
|
||||
config: this.config,
|
||||
logger: this.logger,
|
||||
};
|
||||
|
||||
return _.head(loadPlugin(this.config, this.config.store, plugin_params, function(plugin) {
|
||||
return plugin.getPackageStorage;
|
||||
}));
|
||||
this._setSecret(config);
|
||||
}
|
||||
|
||||
addPackage(name: string, pkg: Package, callback: Callback) {
|
||||
|
@ -857,6 +835,32 @@ class LocalStorage implements IStorage {
|
|||
hash.url = UrlNode.format(tarballUrl);
|
||||
}
|
||||
}
|
||||
|
||||
_setSecret(config: Config) {
|
||||
this.localData.setSecret(config.checkSecretKey(this.localData.getSecret()));
|
||||
}
|
||||
|
||||
_loadStorage(config: Config, logger: Logger) {
|
||||
const Storage = this._loadStorePlugin();
|
||||
|
||||
if (_.isNil(Storage)) {
|
||||
return new LocalDatabase(this.config, logger);
|
||||
} else {
|
||||
return Storage;
|
||||
}
|
||||
}
|
||||
|
||||
_loadStorePlugin() {
|
||||
const plugin_params = {
|
||||
config: this.config,
|
||||
logger: this.logger,
|
||||
};
|
||||
|
||||
return _.head(loadPlugin(this.config, this.config.store, plugin_params, function(plugin) {
|
||||
return plugin.getPackageStorage;
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LocalStorage;
|
||||
|
|
Loading…
Add table
Reference in a new issue