mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
31 lines
690 B
JavaScript
31 lines
690 B
JavaScript
var request = require('request');
|
|
var URL = require('url');
|
|
|
|
function Storage(name, config) {
|
|
if (!(this instanceof Storage)) return new Storage(config);
|
|
this.config = config;
|
|
this.name = name;
|
|
this.ca;
|
|
|
|
if (URL.parse(this.config.uplinks[this.name].url).hostname === 'registry.npmjs.org') {
|
|
this.ca = require('./npmsslkeys');
|
|
}
|
|
return this;
|
|
}
|
|
|
|
Storage.prototype.get_package = function(name, callback) {
|
|
request({
|
|
url: this.config.uplinks[this.name].url + '/' + name,
|
|
json: true,
|
|
headers: {
|
|
'User-Agent': this.config.user_agent,
|
|
},
|
|
ca: this.ca,
|
|
}, function(err, res, body) {
|
|
if (err) return callback(err);
|
|
callback(null, body);
|
|
});
|
|
}
|
|
|
|
module.exports = Storage;
|
|
|