Skip to content

Commit

Permalink
Change naming in fallbacks for more clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
pbazydlo committed Mar 10, 2017
1 parent 5f6b306 commit c35ef82
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/registry/routes/component-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ function componentInfo(err, req, res, component) {

module.exports = function(conf, repository){
return function(req, res){
repository.getComponent(req.params.componentName, req.params.componentVersion, function(localRegistryError, localComponent){
if(localRegistryError && conf.fallbackRegistryUrl) {
return getComponentFallback.getComponentInfo(conf, req, res, localRegistryError, function(error, component){
componentInfo(error, req, res, component);
repository.getComponent(req.params.componentName, req.params.componentVersion, function(registryError, component){
if(registryError && conf.fallbackRegistryUrl) {
return getComponentFallback.getComponentInfo(conf, req, res, registryError, function(fallbackError, fallbackComponent){
componentInfo(fallbackError, req, res, fallbackComponent);
});
}

componentInfo(localRegistryError, req, res, localComponent);
componentInfo(registryError, req, res, component);
});
};
};
10 changes: 5 additions & 5 deletions src/registry/routes/component-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ function componentPreview(err, req, res, component) {
module.exports = function(conf, repository){
return function(req, res){

repository.getComponent(req.params.componentName, req.params.componentVersion, function(localRegistryError, localComponent){
repository.getComponent(req.params.componentName, req.params.componentVersion, function(registryError, component){

if(localRegistryError && conf.fallbackRegistryUrl) {
return getComponentFallback.getComponentPreview(conf, req, res, localRegistryError, function(error, component){
componentPreview(error, req, res, component);
if(registryError && conf.fallbackRegistryUrl) {
return getComponentFallback.getComponentPreview(conf, req, res, registryError, function(fallbackError, fallbackComponent){
componentPreview(fallbackError, req, res, fallbackComponent);
});
}

componentPreview(localRegistryError, req, res, localComponent);
componentPreview(registryError, req, res, component);

});
};
Expand Down
14 changes: 7 additions & 7 deletions src/registry/routes/helpers/get-component-fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var url = require('url');
var urlBuilder = require('../../domain/url-builder');
var _ = require('underscore');

function getComponentFallbackForViewType(buildUrl, conf, req, res, localRegistryError, callback) {
function getComponentFallbackForViewType(buildUrl, conf, req, res, registryError, callback) {
var path = buildUrl({
name: req.params.componentName,
version: req.params.componentVersion
Expand All @@ -24,13 +24,13 @@ function getComponentFallbackForViewType(buildUrl, conf, req, res, localRegistry
}

if (fallbackErr) {
return callback({localError: localRegistryError, fallbackError: fallbackErr});
return callback({registryError: registryError, fallbackError: fallbackErr});
}

try {
return callback(null, JSON.parse(fallbackResponse));
} catch (parseError) {
return callback({localError: localRegistryError, fallbackError: 'Could not parse fallback response: ' + fallbackResponse});
return callback({registryError: registryError, fallbackError: 'Could not parse fallback response: ' + fallbackResponse});
}
});
}
Expand Down Expand Up @@ -61,10 +61,10 @@ module.exports = {
return callback(res[0]);
});
},
getComponentPreview: function (conf, req, res, localRegistryError, callback) {
getComponentFallbackForViewType(urlBuilder.componentPreview, conf, req, res, localRegistryError, callback);
getComponentPreview: function (conf, req, res, registryError, callback) {
getComponentFallbackForViewType(urlBuilder.componentPreview, conf, req, res, registryError, callback);
},
getComponentInfo: function (conf, req, res, localRegistryError, callback) {
getComponentFallbackForViewType(urlBuilder.componentInfo, conf, req, res, localRegistryError, callback);
getComponentInfo: function (conf, req, res, registryError, callback) {
getComponentFallbackForViewType(urlBuilder.componentInfo, conf, req, res, registryError, callback);
}
};

0 comments on commit c35ef82

Please sign in to comment.