title: Defining a ExpressJS route from a Typescript class
body: <p>I'm trying to load <code>ExpressJS</code> routes from a Typescript class. The idea is that this should eventually be dynamic routes. But I'm already stuck at defininghard coded routes in a class.</p>
  
  <p>My <code>index.ts</code> js looks like this:</p>
  
  <pre><code>import generic = require('./generic');
  import Generic = generic.Generic;
  
  class Test {
  
    private app:any;
    private port:number = 3000;
  
    constructor() {
      this.app = express();
      new Generic();
      this.app.listen(this.port, () =&gt; {
        console.log('Listening on port ' + this.port);
      });
    }
  }
  
  export = Test;
  new Test();
  </code></pre>
  
  <p>Then my <code>generic.ts</code> looks like this. I'm trying to define another route from this class:</p>
  
  <pre><code>module Generic {
    export class Generic {
  
      constructor() {
        console.log('In generic');
  
        var router:any = express.Router();
  
        router.get('/', function (req, res) {
          res.setHeader('Content-Type', 'application/json');
          res.status(200).send("AAA");
        });
      }
    }
  }
  export = Generic;
  </code></pre>
  
  <p>When I run my application then I see the message <strong><em>In generic</em></strong> appear in console. But when I load my browser it says:</p>
  
  <pre><code>Cannot GET /
  </code></pre>
  
  <p>So for some reason it's not really registering the route from the <code>Generic</code> class. What am I doing wrong?</p>