In my NodeJS express application I have app.js that has a few common routes. Then in a wf.js file I would like to define a few more routes.
How can I get app.js to recognize other route handlers defined in wf.js file?
A simple require does not seem to work.
If you want to put the routes in a separate file, for example
routes.js, you can create theroutes.jsfile in this way:And then you can require it from
app.jspassing theappobject in this way:Have a look at these examples: https://github.com/visionmedia/express/tree/master/examples/route-separation