meddelare-server
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -92,3 +92,11 @@ var express = require("express"); | ||
function retrieveCount(url, networks) { | ||
function retrieveCount(url, network) { | ||
if (typeof networkCallbacks[network] === "undefined") { | ||
throw new Error("Unknown network"); | ||
} | ||
return Promise.promisify(networkCallbacks[network])(url); | ||
} | ||
function retrieveCounts(url, networks) { | ||
// Create an object of callbacks for each of the requested networks It is | ||
@@ -100,5 +108,3 @@ // then passed to the Promise library to executed in parallel All results will | ||
networks.forEach(function(network) { | ||
if (typeof networkCallbacks[network] !== "undefined") { | ||
networksToRequest[network] = Promise.promisify(networkCallbacks[network])(url); | ||
} | ||
networksToRequest[network] = retrieveCount(url, network); | ||
}); | ||
@@ -134,3 +140,4 @@ | ||
var url, | ||
networks; | ||
networks, | ||
nonExistantNetworks; | ||
@@ -143,2 +150,10 @@ // Check to see if any networks were specified in the query | ||
networks = req.query.networks.split(","); | ||
nonExistantNetworks = networks.filter(function(network) { | ||
return (typeof networkCallbacks[network] === "undefined"); | ||
}); | ||
if (nonExistantNetworks.length > 0) { | ||
inputErrorAndDie(req, res, next, "Unknown network(s) specified: " + nonExistantNetworks.join()); | ||
} | ||
} | ||
@@ -159,3 +174,3 @@ | ||
retrieveCount(url, networks) | ||
retrieveCounts(url, networks) | ||
.then(function(results) { | ||
@@ -166,3 +181,3 @@ res.jsonp(results); | ||
.catch(function(err) { | ||
console.error("getCount", "catch", "retrieveCount", err); | ||
console.error("getCount", "catch", "retrieveCounts", err); | ||
@@ -169,0 +184,0 @@ serverErrorAndDie(req, res, next, "There was an unknown error."); |
{ | ||
"name": "meddelare-server", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Install custom social share counters on your website with your own hosted solution, which only makes a single API request and loads minimal or zero assets to display the counters.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://meddelare.com/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16438
191