Skip to content

Commit

Permalink
#3 - Updating the promise handler so that it can be used in coffeescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Trevino committed Mar 18, 2015
1 parent 9f7fec0 commit 4157062
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/proxies/promise-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ module.exports = {
name: 'Promise Handler',
init: (delegate) => {
return (req, res, next) => {
if (delegate.length === 2) {
JPromise.resolve(true)
.then(() => delegate(req, res))
.then(() => next())
.catch(next);
} else {
delegate(req, res, next);
let possiblePromise = delegate(req, res, next);
if (possiblePromise && possiblePromise.then) {
possiblePromise.then(() => next()).catch(next);
}
};
}
Expand Down

0 comments on commit 4157062

Please sign in to comment.