Fixes to merge conflicts, updating to master

This commit is contained in:
Michael Uzquiano
2012-11-26 11:18:30 -05:00
142 changed files with 3624 additions and 451 deletions

View File

@@ -7,11 +7,15 @@
// ==========================================
var request = require('request');
var _ = require('underscore');
var config = require('./config');
var endpoint = config.endpoint + '/packages';
if (process.env.HTTP_PROXY) {
request = request.defaults({'proxy': process.env.HTTP_PROXY});
}
// allow for searchpath endpoints to be used for search and lookup
var endpoints = [];
endpoints.push(endpoint);
@@ -21,9 +25,9 @@ if (config.searchpath) {
}
}
// walk all search path endpoints to find the component
exports.lookup = function (name, callback) {
// walk all endpoints to find the first matching component
var f = function(i) {
var endpoint = endpoints[i];
request.get(endpoint + '/' + encodeURIComponent(name), function (err, response, body) {
@@ -47,12 +51,11 @@ exports.lookup = function (name, callback) {
f(0);
};
exports.register = function (name, url, callback) {
var body = {name: name, url: url};
request.post({url: endpoint, form: body}, function (err, response, body) {
request.post({url: endpoint, form: body}, function (err, response) {
if (err) return callback(err);
if (response.statusCode === 406) {
@@ -71,11 +74,9 @@ exports.register = function (name, url, callback) {
});
};
// walks all searchpath endpoints and produces federated search results
exports.search = function (name, callback) {
// walk all endpoints to produced federated search results
var f = function(i, map, results) {
var endpoint = endpoints[i];
request.get(endpoint + '/search/' + encodeURIComponent(name), function (err, response, body) {
@@ -106,8 +107,6 @@ exports.search = function (name, callback) {
f(0, {}, []);
};
exports.info = function (name, callback) {
exports.lookup(name, function (err, url) {
if (err) return callback(err);
@@ -123,11 +122,9 @@ exports.info = function (name, callback) {
});
};
// walks all searchpath endpoints and produces federated results
exports.all = function (callback) {
// walk all endpoints to produced federated search results
var f = function(i, results) {
var endpoint = endpoints[i];
request.get(endpoint, function (err, response, body) {