controller.js
function(req, res, next) {
    var data = res.data || null;
    var code = 200;
    if (_.isNumber(res.code)) {
      code = res.code;
    }
    var envelope = {
      meta: {
        code: code
      },
      data: data
    };

    // Optional paging meta
    if (res.paging) {
      envelope.meta.paging = res.paging;
    }

    // Set code and data
    res.code = code;
    if (res.code !== 204) {
      res.data = envelope;
    }

    return next();
  }
function(req, res, next) {
    var data = res.data || null;
    var code = 200;
    if (_.isNumber(res.code)) {
      code = res.code;
    }
    var envelope = {
      meta: {
        code: code
      },
      data: data
    };

    // Optional paging meta
    if (res.paging) {
      envelope.meta.paging = res.paging;
    }

    // Set code and data
    res.code = code;
    if (res.code !== 204) {
      res.data = envelope;
    }

    return next();
  }
function ( req , res , next ) { var data = res . data || null ; var code = 200 ; if ( _ . isNumber ( res . code ) ) { code = res . code ; } var envelope = { meta : { code : code } , data : data } ; // Optional paging meta if ( res . paging ) { envelope . meta . paging = res . paging ; } // Set code and data res . code = code ; if ( res . code !== 204 ) { res . data = envelope ; } return next ( ) ; }
Default middleware for handling successful responses
Default middleware for handling successful responses