how to require a class in node.js
<p>my code that works..</p>

<pre><code>var express=require("express"),
app=express();

class bar {
   constructor()
   {
     this.user_name=null;
     this.user_surname=null;
     this.user_age=null;
   }

   name(user_name) {
     this.user_name=user_name;
     return this;
   }

   surname(user_surname) {
     this.user_surname=user_surname;
     return this;
   }

   age(user_age) {
     this.user_age=user_age;
     return this;
   }

   get(callback) {

     var list ={};

     list.uname=this.user_name;
     list.usurname=this.user_surname;
     list.uage=this.user_age;

     callback(list);
   }

}



app.get("/liste/:ext",function(req,res){

  var ext=req.params.ext;

  res.setHeader('Content-Type', 'application/json');

  if(ext==1)
  {
    var newbar=new bar();
    newbar.name("alex").surname("broox").age(32).get(function(result){
      res.json({data:result})
    })

  }

  if(ext==2)
  {
    var newbar=new bar();
    newbar.name("alex2").get(function(result){
      res.json({data:result})
    })
  }

})

app.listen(4000,function(log){
  console.log("listening")
})
</code></pre>

<p>but..following code does not work.. with require that class from other file..</p>

<p>test.js</p>

<pre><code>module.exports = {

class bar {
   constructor()
   {
     this.user_name=null;
     this.user_surname=null;
     this.user_age=null;
   }

   name(user_name) {
     this.user_name=user_name;
     return this;
   }

   surname(user_surname) {
     this.user_surname=user_surname;
     return this;
   }

   age(user_age) {
     this.user_age=user_age;
     return this;
   }

   get(callback) {

     var list ={};

     list.uname=this.user_name;
     list.usurname=this.user_surname;
     list.uage=this.user_age;

     callback(list);
   }

}

};
</code></pre>

<p>app.js file.. with require that class</p>

<pre><code>var express=require("express"),
app=express();


require("./test")



app.get("/liste/:ext",function(req,res){

  var ext=req.params.ext;

  res.setHeader('Content-Type', 'application/json');

  if(ext==1)
  {
    var newbar=new bar();
    newbar.name("alex").surname("broox").age(32).get(function(result){
      res.json({data:result})
    })

  }

  if(ext==2)
  {
    newbar.name("alex2").get(function(result){
      res.json({data:result})
    })
  }

})

app.listen(4000,function(log){
  console.log("listening")
})
</code></pre>

<p>but why does not it work...please help me..above code that works but this code that does not work.. </p>