Great article; a few things I would add. I use bluebird for Promises, which is just the most fantastic Promises lib ever conceived, no joke; if you haven't used it try it. So some of these may be Bluebird-specific:<p>1. Don't wrap callback functions manually with `new Promise(function(resolve, reject) {...})`, just use `Promise.promisify(...)`. For one-off functions, try `Promise.fromNode(function(cb) { fs.readFile('..', cb); });`.<p>2. This pattern:<p><pre><code> getUserByName('nolan').then(function (user) {
return getUserAccountById(user.id);
}).then(function (userAccount) {
// I got a user account!
});
</code></pre>
Could be:<p><pre><code> getUserByName('nolan')
.get('id')
.then(getUserAccountById)
.then(function (userAccount) {
// I got a user account!
});
</code></pre>
3. I too used Promise.resolve().then(...) to start a lot of route handlers. Try `Promise.try(function() {...})`, which is equivalent but reduces the temptation to just stick a synchronous value in the `Promise.resolve()` just because you can.<p>4. `Promise#nodeify()` is <i>super</i> useful for creating functions that return promises or use callbacks depending on how they're called. For example:<p><pre><code> function getUserName(id, cb) {
return db.getUserAsync(id).get('name')
.nodeify(cb);
}
</code></pre>
Is the same as:<p><pre><code> function getUserName(id, cb) {
var promise = db.getUserAsync(id).get('name');
if (!cb) return promise;
promise.then(function(result) { cb(null, result);})
.catch(function(e) { cb(e); });
}
</code></pre>
This is great if you want to convert a few functions you use to promises, but they're called elsewhere and expect a callback style.<p>I'm sure there are many more. This is my bible: <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md" rel="nofollow">https://github.com/petkaantonov/bluebird/blob/master/API.md</a><p>In short; use Promises! They are the answer for callback hell in Node. Async/await may fix more problems in the future but if you want Node/Browser compatibility and to get started right now, Promises are the best way to go.