title: What can be a better way to handle sending response from controller in nodejs project?
body: <p>rooms.js -> controller class for rooms endpoint</p>
  
  <pre><code>router.get('/:roomid/fight/verify', function(req, res) {
        roomModel.authenticateUserForFight(req.params.roomid, req.query.otp, res);
      });
  </code></pre>
  
  <p>roomModel -> model class for rooms</p>
  
  <pre><code>//authenticate user based on otp provided on client side
  exports.authenticateUserForFight = function(roomid, otp, res) {
    db.query('select * from room where roomid=?', [roomid], function(error, rows) {
      if (rows.length == 0) {
        console.log("otp does not exist in db for room:" + roomid);
      } else if (rows.length == 1) {
        var otpInDb = rows[0].otp.toString();
        if (otp == otpInDb) {
          console.log("User is authorised");
          res.status(200);
          res.send("User is authorised");
        } else {
          console.log("User is unauthorised");
          res.status(401);
          res.send("User not authorised");
        }
      }
    });
  }
  </code></pre>
  
  <p><b>This piece of code works fine but is there a better way to send response to client instead of passing res object to model class and setting the status and response message there ? The reason i am passing the res object is because doing res.status and res.send in controller is giving issues as the db call is asynchronous. Suggest some better practices to handle these kind of situtations.
   </b></p>