so basically app.use kinda imports the usage of the module? as in this case we have a routes module which contains all the routes. we exports the routes in the routes/index.js. then we require it in the main app.js file
const routes = ('./routes'); //as by default we have a index.js file so the whole index.js file will, and we are exporting //the whole router function const router = express.Router(); module.exports = router; // here we export the whole router function,whatever middlewares and routes it has. // hence the router will be //exported.
now in the main app.
const routes = require('./routes'); app.use(routes);
and now this router is connected to the main application. my questions are : is my understanding correct? we can import as many modules we'd like via the app.use method? as long as the routes don't collide with each other working. such as two '/' paths or 'about'.