From the course: Building a Website with Node.js and Express.js
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Creating routes for all subpages
From the course: Building a Website with Node.js and Express.js
Creating routes for all subpages
- [Instructor] We just created our first routing module. Let's now go ahead and create the rest of the modules that we need to build up our whole page. I decided to organize each sub-page into a file of its own. For that, I will now add a new file, feedback.js, and a new file, speakers.js, to my routes folder. Before we implement those routing modules, how should we book them into our express application? What I could do now is I could simply just add it here to server.js. So, for instance, something like app.use /speakers, and then have some speakers route, something like that. But this will again add a lot of dependency to the sub-modules that I have. I would rather just have one point in the application where I hook or mount the routes into it. So what I can do instead and which is way more elegant is I can go into my index.js file and add those sub-pages now to that index.js file, which also resembles the overall…