You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
I'm new to express/node development and decided to use this generator to get me started. One major pain point I had was figuring out how to structure the router calls, as all the examples I found was using a single file for all the router files.
I eventually figured out adding the same exports statement worked, after I spent a lot of time trying varients of app.use(/'some-path'). I'm not sure this is ideal, not sure the inner workings of app.use.
`
module.exports = function (app) {
app.use('/', router);
};
router.get('/sometpath', function (req, res, next) {
...
});
`
I suspect if I'd did app.use('/somepath', router); with router.get('/', but haven't tested yet.
I propose adding a article controller with example router paths. I'm willing to work on a PR but figured I'd gauge interest first.
The text was updated successfully, but these errors were encountered:
Hey, yeah I think you worked it out. The app.use sets the base route for the controller, then router.get is after that, so yes you could do app.use('/somepath', then router.get('/' to get the same thing.
hefox
added a commit
to hefox/generator-express
that referenced
this issue
Feb 15, 2017
Hiya!
I'm new to express/node development and decided to use this generator to get me started. One major pain point I had was figuring out how to structure the router calls, as all the examples I found was using a single file for all the router files.
I eventually figured out adding the same exports statement worked, after I spent a lot of time trying varients of app.use(/'some-path'). I'm not sure this is ideal, not sure the inner workings of app.use.
`
module.exports = function (app) {
app.use('/', router);
};
router.get('/sometpath', function (req, res, next) {
...
});
`
I suspect if I'd did app.use('/somepath', router); with router.get('/', but haven't tested yet.
I propose adding a article controller with example router paths. I'm willing to work on a PR but figured I'd gauge interest first.
The text was updated successfully, but these errors were encountered: