1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-24 21:15:51 +01:00

inline documentation

This commit is contained in:
Alex Kocharin 2013-09-25 13:12:33 +04:00
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 info_file = 'package.json';
//
// Implements Storage interface
// (same for storage.js, local-storage.js, up-storage.js)
//
function Storage(config) {
if (!(this instanceof Storage)) return new Storage(config);
this.config = config;

@ -6,10 +6,17 @@ var Local = require('./local-storage');
var Proxy = require('./up-storage');
var utils = require('./utils');
//
// Implements Storage interface
// (same for storage.js, local-storage.js, up-storage.js)
//
function Storage(config) {
if (!(this instanceof Storage)) return new Storage(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 = {};
for (var p in config.uplinks) {
this.uplinks[p] = new Proxy(config.uplinks[p], config);
@ -19,6 +26,9 @@ function Storage(config) {
return this;
}
//
// TODO: badly documented
//
Storage.prototype.add_package = function(name, metadata, callback) {
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) {
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) {
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) {
this.queue(data);
}, function() {
@ -139,6 +166,15 @@ Storage.prototype.get_tarball = function(name, filename, callback) {
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) {
var self = this;
var uplinks = [this.local];

@ -3,6 +3,10 @@ var through = require('through');
var UError = require('./error').UserError;
var URL = require('url');
//
// Implements Storage interface
// (same for storage.js, local-storage.js, up-storage.js)
//
function Storage(config, mainconfig) {
if (!(this instanceof Storage)) return new Storage(config);
this.config = config;