title: Express can't reach route
body: <p>I have the following file: (<code>auth.js</code>)</p>
  
  <pre><code>module.exports = function (express, mongoose, router) {
  
      router.route('/setup')
          .get(function (req, res) {
              var salt = bcrypt.genSaltSync(10);
              var hashed =  bcrypt.hashSync(req.query.password, salt);
              // create a sample user
              mongoose.models.playlist.create({username: 'Hieratic', password: hashed}, function (err, item) {
  
                  if (err) throw err;
  
                  console.log('User saved successfully');
                  res.json({ success: true });
              });
  
          });
  
  
      return router;
  };
  </code></pre>
  
  <p>And the current server file: (<code>server.js</code>)</p>
  
  <pre><code>    "use strict";
  
  var url = require('url');
  var express = require('express');
  var bodyParser = require('body-parser');
  var fs = require('fs');
  var crypto = require('crypto');
  //npm install request
  var request = require('request');
  var config = require('./config/access.json');
  var admin = require("firebase-admin");
  var fireBaseConfig = require('./config/firebase.config.json');
  var mongoose = require('mongoose');
  var MongoClient = require('mongodb').MongoClient;
  var mongodbConfig = require('./config/database.json');
  var exec = require('child-process-promise').exec;
  var app = express();
  
  /**
   * Schemas
   */
  var UserModel = require('./schemas/user.schema.js')(mongoose);
  var PlayListModel = require('./schemas/playlist.schema.js')(mongoose);
  
  
  app.use(function (req, res, next) {
      // CORS headers
      res.header('Access-Control-Allow-Origin', '*');
      res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
      res.header("Access-Control-Allow-Headers",
          "Origin, X-Requested-With, Content-Type, Accept, x-access-token, Cache-Control, Pragma"
      );
      next();
  });
  var router = express.Router();
  app.use(bodyParser.json({limit: '4mb'}));
  app.use(bodyParser.urlencoded({
      extended: true,
      limit: '4mb'
  }));
  
  if (mongodbConfig.username &amp;&amp; mongodbConfig.password) {
      mongoose.connect(`mongodb://${mongodbConfig.username}:${mongodbConfig.password}@${mongodbConfig.host}:${mongodbConfig.port}/${mongodbConfig.database}`);
  }
  else {
      mongoose.connect(`mongodb://${mongodbConfig.host}:${mongodbConfig.port}/${mongodbConfig.database}`);
  }
  process.on('disconnect', function () {
      // If mongodb connection is not terminated child process never dies
      mongoose.disconnect();
  });
  require('./auth.js')(express, mongoose, router);
  
  
  var port = 51000;
  app.listen(port);
  console.log('Magic happens at http://localhost:' + port);
  </code></pre>
  
  <p>When i attempt to access the <code>/setup</code> route it does hit the server however it throws an html page:</p>
  
  <p>(<code>http://localhost:51000/setup</code>):</p>
  
  <pre><code>&lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Error&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;pre&gt;Cannot GET /setup&lt;/pre&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Can anyone see what ive done wrong?</p>