Update routes for bluebird

This commit is contained in:
Jonathan Cremin 2014-12-13 00:10:41 +00:00
parent 17de5e9b92
commit 99f0d1bef6
4 changed files with 10 additions and 9 deletions

View file

@ -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) {

View file

@ -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",

View file

@ -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('/');

View file

@ -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;