lib/responses.js
function expectJSON(fn, res) {
  bluebird.try(fn).then(function (result) {
    res.json(result);
  }).catch(handleError(res));
}
function expectJSON(fn, res) {
  bluebird.try(fn).then(function (result) {
    res.json(result);
  }).catch(handleError(res));
}
function expectJSON ( fn , res ) { bluebird . try ( fn ) . then ( function ( result ) { res . json ( result ) ; } ) . catch ( handleError ( res ) ) ; }
Reusable code to return JSON data, both for good results AND errors.

Captures and hides appropriate errors.

These return JSON always, because these endpoints are JSON-only.
@param {function} fn
@param {object} res
Reusable code to return JSON data both for good results AND errors .