DEV Community

Concept: High Performance web server w/ Promises

Frank@theOpenSourceU.org on February 05, 2018

Purpose My intended purpose is to provide a higher level of throughput -- service more requests per second through an async API. It ...
Collapse
 
mrm8488 profile image
Manuel Romero • Edited

Try this:

/* GET home page. */
router.get('/', function(req, res, next) {
  return new Promise(function(resolve, reject) {
    debug("GET /");
    resolve({ title: 'The Open Source U' }); //calculation or object
  })
  .then(function(payload) {
    res.render('site/index', payload)
  });
});
Collapse
 
theopensourceu profile image
Frank@theOpenSourceU.org • Edited

I'm replacing my previous comment about next. I think I see what you are pointing out. I'm revisiting this based on your feedback.