mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-03-11 02:15:57 -05:00
inline documentation
This commit is contained in:
parent
34a52f09a2
commit
4791d0e707
3 changed files with 45 additions and 1 deletions
|
@ -7,6 +7,10 @@ var UError = require('./error').UserError;
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var info_file = 'package.json';
|
var info_file = 'package.json';
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implements Storage interface
|
||||||
|
// (same for storage.js, local-storage.js, up-storage.js)
|
||||||
|
//
|
||||||
function Storage(config) {
|
function Storage(config) {
|
||||||
if (!(this instanceof Storage)) return new Storage(config);
|
if (!(this instanceof Storage)) return new Storage(config);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
|
@ -6,10 +6,17 @@ var Local = require('./local-storage');
|
||||||
var Proxy = require('./up-storage');
|
var Proxy = require('./up-storage');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implements Storage interface
|
||||||
|
// (same for storage.js, local-storage.js, up-storage.js)
|
||||||
|
//
|
||||||
function Storage(config) {
|
function Storage(config) {
|
||||||
if (!(this instanceof Storage)) return new Storage(config);
|
if (!(this instanceof Storage)) return new Storage(config);
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
|
// we support a number of uplinks, but only one local storage
|
||||||
|
// Proxy and Local classes should have similar API interfaces
|
||||||
this.uplinks = {};
|
this.uplinks = {};
|
||||||
for (var p in config.uplinks) {
|
for (var p in config.uplinks) {
|
||||||
this.uplinks[p] = new Proxy(config.uplinks[p], config);
|
this.uplinks[p] = new Proxy(config.uplinks[p], config);
|
||||||
|
@ -19,6 +26,9 @@ function Storage(config) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: badly documented
|
||||||
|
//
|
||||||
Storage.prototype.add_package = function(name, metadata, callback) {
|
Storage.prototype.add_package = function(name, metadata, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -59,15 +69,32 @@ Storage.prototype.add_package = function(name, metadata, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: badly documented
|
||||||
|
//
|
||||||
Storage.prototype.add_version = function(name, version, metadata, tag, callback) {
|
Storage.prototype.add_version = function(name, version, metadata, tag, callback) {
|
||||||
this.local.add_version(name, version, metadata, tag, callback);
|
this.local.add_version(name, version, metadata, tag, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upload a tarball to a storage for {name} package
|
||||||
|
//
|
||||||
|
// Function is syncronous and returns a WritableStream
|
||||||
|
//
|
||||||
|
// Used storages: local
|
||||||
|
//
|
||||||
Storage.prototype.add_tarball = function(name, filename) {
|
Storage.prototype.add_tarball = function(name, filename) {
|
||||||
return this.local.add_tarball(name, filename);
|
return this.local.add_tarball(name, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage.prototype.get_tarball = function(name, filename, callback) {
|
//
|
||||||
|
// Get a tarball from a storage for {name} package
|
||||||
|
//
|
||||||
|
// Function is syncronous and returns a ReadableStream
|
||||||
|
//
|
||||||
|
// TODO: badly documented
|
||||||
|
//
|
||||||
|
Storage.prototype.get_tarball = function(name, filename) {
|
||||||
var stream = through(function(data) {
|
var stream = through(function(data) {
|
||||||
this.queue(data);
|
this.queue(data);
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -139,6 +166,15 @@ Storage.prototype.get_tarball = function(name, filename, callback) {
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve a package metadata for {name} package
|
||||||
|
//
|
||||||
|
// Function invokes local.get_package and uplink.get_package for every
|
||||||
|
// uplink with proxy_access rights against {name} and combines results
|
||||||
|
// into one json object
|
||||||
|
//
|
||||||
|
// Used storages: local && uplink (proxy_access)
|
||||||
|
//
|
||||||
Storage.prototype.get_package = function(name, callback) {
|
Storage.prototype.get_package = function(name, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var uplinks = [this.local];
|
var uplinks = [this.local];
|
||||||
|
|
|
@ -3,6 +3,10 @@ var through = require('through');
|
||||||
var UError = require('./error').UserError;
|
var UError = require('./error').UserError;
|
||||||
var URL = require('url');
|
var URL = require('url');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implements Storage interface
|
||||||
|
// (same for storage.js, local-storage.js, up-storage.js)
|
||||||
|
//
|
||||||
function Storage(config, mainconfig) {
|
function Storage(config, mainconfig) {
|
||||||
if (!(this instanceof Storage)) return new Storage(config);
|
if (!(this instanceof Storage)) return new Storage(config);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
Loading…
Add table
Reference in a new issue