module.exports = function (app) {

  var P = app.Promise;
  var db = app.db;

  var util = require('../util');
  var dao = require('../dao')(app);

  return {
    create: function (req, res) {
      util.checkParams(req.body, ['description', 'date']);

      db.sequelize.transaction(function (t) {
        return dao.User.getByUsername(req.session.username, t)
          .then(function (user) {
            if (!user) util.sendError(400, util.Error.ERR_ENTITY_NOT_FOUND, "User from token does not exist");
            else return dao.Order.create(req.body, user, t);
          })
      })
        .then(util.jsonResponse.bind(util, res))
        .catch(util.sendError.bind(util, res, 400, util.Error.ERR_BAD_REQUEST))
        .done();
    },

    getById: function (req, res) {
      if (!req.params.id) util.stdErr500(res, "Missing parameter 'id'");
      else
        db.Order.find({where: {id: req.params.id, include: [Client, Shop]}})
          .success(util.stdSeqSuccess.bindLeft(res), util.stdSeqError.bindLeft(res))
          .done();
    },

    getOrders: function (req, res) {
      dao.Order.getUserOrders(req.session.username, {})
        .then(util.jsonResponse.bind(util, res))
        .catch(util.sendError.bind(util, res, 400, util.Error.ERR_BAD_REQUEST))
        .done();
    }
  }
}

@@ -782,227 +782,159 @@
     
-if (!req.params.id) util.stdErr500(res, %22Missing parameter 
+util.checkParams(req.params, %5B
 'id'
-%22);%0A      else%0A  
+%5D);%0A%0A
       d
-b
+ao
 .Order.
-find(%7Bwhere: %7Bid: req.params.id, include: %5BClient, Shop%5D%7D%7D)%0A          .success(util.stdSeqSuccess.bindLeft(res), 
+getById(req.params.id)%0A        .then(util.jsonResponse.bind(util, res))%0A        .catch(
 util.s
-tdSeq
+end
 Erro
@@ -943,21 +943,54 @@
 bind
-Left(res
+(util, res, 400, util.Error.ERR_BAD_REQUEST
 ))%0A
-  
     

Fix getById() controller