- First step is create a separate folder for routes and lets name it as "routes".
- Next create
index.js
file in "routes" directory
After this step the project structure will look like this.
|--routes | |-index.js |--views | |-default.js |--app.js
- Export routes in
index.js
file.
exports.index = function(req,res){ res.render('default',{title:"Home"}); }
- Require the routes folder in
app.js
file
var routes = require('./routes');
- Provide methods in
index.js
file toget
method of Express when cofiguring routes
app.get('/',routes.index);
In this way we can modularize our routes in node.js app and we can have a clean and understandable code.
Thanks for posting this article.
ReplyDeleteFull Stack Training in Hyderabad
Full Stack Training in Ameerpet
Full Stack Training Institute
Great blog article informative I liked it
ReplyDeleteWe are the best piping design course in Hyderabad, India. Sanjary academy Offers Piping Design Course and Best Piping Design Training Institute in Hyderabad. Piping Design Institute in India Piping Design Engineering.
best Piping Design Course
piping design course with placement
pipe stress analysis course in hyderabad
piping engineering course in hyderabad
piping stress analysis course
best Piping Design institute
best institute of Piping Design Course in India
Piping Design Course
Piping Design Course in India
There are several factors that could affect Internet speed. You have to address them one at a time
ReplyDeleteData Science Training in Gurgaon
Saleforce Training in Gurgaon