I'm new to Node/Express, and I think this is a simple ask, but I'm not quite if my logic/understanding is sound.
Here's a simplified version of my app structure:
/app
/routes
filter.js
index.js
app.js
I've got my routes defined in my app.js file like this.
// app.js
app.use('/', require('./routes/index'));
app.use('/filterone', require('./routes/filter'));
app.use('/filtertwo', require('./routes/filter'));
I'd like to point traffic from both /filterone and /filtertwo to my filter.js route, and then in the route I'd like to handle them like this:
// filter.js
router.get('/filterone', function(req, res, next) {
// do something
}
router.get('/filtertwo', function(req, res, next) {
// do something
}
Is that the correct way to go about doing this? Or should I be handling my routes differently?