title: Route isn't calling when it's defined in a separated file
body: <p>I'm trying to structure my node app according to some best practices mentioned <a href="https://github.com/i0natan/nodebestpractices/blob/master/sections/projectstructre/breakintcomponents.md" rel="nofollow noreferrer">here</a> . </p>
  
  <p>But I'm having problems when calling the specific routes.</p>
  
  <p>This is my server.js file</p>
  
  <pre><code>const express = require("express");
  const bodyParser = require("body-parser");
  const normalizePort = require("./utils/normalize-port");
  
  const app = express();
  const port = normalizePort(process.env.PORT || 5000);
  app.set("port", port);
  
  require("./components/users");
  
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  require("./config/database");
  
  app.listen(port, () =&gt; console.log(`Application started on port : ${port}`));
  </code></pre>
  
  <p>And this is my <em>index.js</em> file in <code>/components/users/</code></p>
  
  <pre><code>const router = require("express").Router();
  const user = require("./users")(router);
  
  module.exports = { user };
  </code></pre>
  
  <p>And this is my <em>users.js</em> file which is in the same directory as above <em>index.js</em> .</p>
  
  <pre><code>module.exports = router =&gt; {
    console.log("Hello at First");
    router.get("/hello", (req, res) =&gt; {
      console.log("hello");
      res.send("hello");
    });
  };
  </code></pre>
  
  <p>Now when I start server in <code>http://localhost:5000</code> the console logs the message like this</p>
  
  <pre><code>Hello at First
  Application started on port : 5000
  </code></pre>
  
  <p>So, it means the file is calling, right ? But when I tried to connect to <code>http://localhost:5000/hello</code> which I've defined in <code>users.js</code> it gives the error of <code>Cannot GET /hello</code> . As I'm gonna define multiple routes in <em>/components/users</em> folder only I created <code>index.js</code> file to export all from a single file. How can I fix this by keeping the same structure ?</p>
  
  <p>Why is that ? Why my route isn't calling ?</p>