title: Returning an Object from middleware function in Node.JS
body: <p>I am new to Node.JS coming from a Java Background I am using express to build this Rest API . What I am trying to do is build the concept of a manager. I am looking for a elegant way of returning a user object in the following:</p>
  
  <p>users route: user.js</p>
  
  <pre><code>router.get('/find/:email', function(req, res, next){
    userWare.findUserByEmail(req, res, next)
  });
  </code></pre>
  
  <p>middleware/manager: usermiddleware.js</p>
  
  <pre><code>module.exports = {
      findUserByEmail: function(req, res, next) {
          models.core_user.find({
              where:{
                  email: req.params.email
              }
          }).then(function(user){
              res.json(user)
          }, function(err){
              res.status(404).json(err);
          });
      },
  }
  </code></pre>
  
  <p>So In this above function I would like to return the user object to the route instead of the json. so that I can create the json from the object in the route. The whole point of this manager class will be to fectch and return objects.</p>