Update routes for bluebird
This commit is contained in:
parent
17de5e9b92
commit
99f0d1bef6
4 changed files with 10 additions and 9 deletions
|
@ -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('/');
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue