title: Express proper way to handle routing
body: <p>See my situation is that I had initialized the express.js library  to a variable and was asking is there a way to pass the express variable from app.js to users.js .My understanding was it cannot be done and I had to import it in users.js seperately if I wanted to use express libraries functions in user.js</p>
  
  <p>Then I saw the below apporach</p>
  
  <p>What I saw was 
  App.js</p>
  
  <pre><code>var express= require('express');
  var app = express();
  //Some code...
  //Some code...
    var users = require('./routes/users.js');
    app.use('/',users);
  </code></pre>
  
  <p>Routes/User.js</p>
  
  <pre><code>   module.exports = (app,passport) = &gt; {
     app.get('/route/',(req,res)=&gt;{
  
    });
  
  }
  </code></pre>
  
  <p>What I was doing until now was to require it in that js file as well .So what is the best way to handle such a situation </p>
  
  <p>App.js</p>
  
  <pre><code>var express= require('express');
  var app = express();
  
  //Some code...
  //Some code...
    var users = require('./routes/users.js');
    app.use('/',users);
  </code></pre>
  
  <p>Routes/User.js</p>
  
  <pre><code>var express= require('express');
  var router= express();
  
     router.get('/route/',(req,res)=&gt;{
       //some action
    });
  
   module.exports = router;
  </code></pre>
  
  <p>And also how using ecma script the variable </p>
  
  <p><strong>EDIT :-</strong></p>
  
  <p>How does this code work without importing the express variable in users.js
  app.js</p>
  
  <pre><code>var express= require('express');
  var app = express();
  
  var users = require('./routes/users.js');
  app.use('/',users);
  </code></pre>
  
  <p>route/users.js</p>
  
  <pre><code>module.exports = (app)=&gt;{
  
      app.get('',(req,res)=&gt;{
     //some code
     });
  }
  </code></pre>