diff --git a/lib/playmusic.js b/lib/playmusic.js index 62785b9..b0048f4 100644 --- a/lib/playmusic.js +++ b/lib/playmusic.js @@ -97,6 +97,9 @@ PlayMusic.prototype.init = function(config, next) { this._key = s1; this._login(function(err, response) { + if (err) { + return next(err); + } that._token = response.Auth; that._getXt(function(err, xt) { if (err) { diff --git a/package.json b/package.json index 49b8fd9..24540b6 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "morgan": "~1.3.0", "node-uuid": "^1.4.2", "promised-mongo": "^0.11.1", - "q": "^1.1.2", "rdio": "^1.5.2", "serve-favicon": "~2.1.3", "spotify": "^0.3.0", diff --git a/routes/search.js b/routes/search.js index dd3621e..1f3f164 100644 --- a/routes/search.js +++ b/routes/search.js @@ -1,7 +1,6 @@ "use strict"; var parse = require('url').parse; var path = require('path'); -var Q = require('q'); var services = {}; @@ -24,7 +23,7 @@ module.exports = function(req, res, next) { var matched = services[id].match(req.body.url); if (matched) { searching = true; - Q.timeout(services[id].parseUrl(req.body.url), 5000).then(function(result) { + services[id].parseUrl(req.body.url).timeout(10000).then(function(result) { if (!result.id) { req.flash('search-error', 'No match found for this link'); res.redirect('/'); diff --git a/routes/share.js b/routes/share.js index aad2671..aadad3d 100644 --- a/routes/share.js +++ b/routes/share.js @@ -1,6 +1,6 @@ "use strict"; var path = require('path'); -var Q = require('q'); +var Promise = require('bluebird'); var services = {}; @@ -33,17 +33,17 @@ module.exports = function(req, res, next) { thisUrl: req.userProtocol + '://' + req.get('host') + req.originalUrl }); } else { - Q.timeout(services[serviceId].lookupId(itemId, type), 5000).then(function(item) { + services[serviceId].lookupId(itemId, type).timeout(10000).then(function(item) { for (var id in services) { if (id != serviceId) { - promises.push(Q.timeout(services[id].search(item), 10000)); + promises.push(services[id].search(item).timeout(10000)); } } - Q.allSettled(promises).then(function(results) { + Promise.settle(promises).then(function(results) { var items = results.map(function(result) { - if (result.state == "fulfilled") { - return result.value; + if (result.isFulfilled()) { + return result.value(); } }).filter(function(result) { return result || false;