title: What is going wrong with the class defination in expressjs?
body: <p>I have added a response class in expressjs as follows</p>
  
  <pre><code>module.exports = function(req,res) {
    this.req = req;
    this.res = res;
    console.log(this.res);
  
    this.ok = function() {
      this.res.status(200).end();
    }
  
    this.err = function(err) {
      console.log(this.res);
      this.res.status(400).json({err:err.message});
    }
  };
  </code></pre>
  
  <p>And i am calling it using</p>
  
  <pre><code>route.post("/",function(req,res){
    var authCtx = new authHelper(req,res);
    var respCtx = new response(req,res);
    authCtx.checkForm()
      .then(respCtx.ok)
      .catch(respCtx.err);
  });
  </code></pre>
  
  <p>The problem is when i create an object of class the first <code>console.log</code> prints the complete response fine without any errors but in second case when error is invoked the <code>this.res</code> becomes empty. Where am i going wrong with this ?</p>