title: How do we modularize files and then use in firebase cloud functions when using expressjs
body: <p>I am using express in firebase cloud functions.
  So my index.js needs to be moularized and split into different files.
  What is the best way to do it.</p>
  
  <p>I know that there is a SO post to how we can modularize nodejs apps, i just want to know how we could do the same if we use express.</p>
  
  <p><code>test.js</code></p>
  
  <pre><code> var express = require('express');
      var router = express.Router();
  
      router.get('/test', function (req, res) {
        res.json(200, {'test': 'it works!'});
      });
  
      module.exports = router;
  </code></pre>
  
  <p><code>index.js</code></p>
  
  <pre><code>var test = require("./routes/test.js");
  var other = require("./routes/other.js");
  ...
  //all your code for creating app 
  ...
  app.use('/test', test);
  app.use('/other', other);
  </code></pre>
  
  <p>can we do something like this in firebase cloud functions when using with nodejs</p>
  
  <p>and then export them like below:</p>
  
  <p><code>exports.app = functions.https.onRequest(app);</code></p>
  
  <p>Or is there any correct way to do it in case of express.</p>
  
  <p>Thanks</p>