I am a newbie in Node.js (and Express) and I am trying to make sense of this. Say I have a website with 3 pages (can be GET or POST): /, /page1, /page2. What should I do so that every page is handled by a separate JS file?
app.all('/', function(request, response)
{
// Get home.js to handle this request and response
});
app.all('/page1', function(request, response)
{
// Get page1.js to handle this request and response
});
app.all('/page2', function(request, response)
{
// Get page2.js to handle this request and response
});
Better yet, is there a way to define a wildcard so there is not so much repetition? Something like this:
app.all('*', function(request, response)
{
// Get *.js to handle this request and response. * is whatever the URI string is
});
Continuing my discussion with @Alex. Here’s how I did it. Any gotcha?