-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
posts-project/src/controllers/index.js
Line 15 in 543acb9
| router.get('/', getHomePage); |
it's much better for readability to cluster your route handling based on the route requested rather than having what you are doing now.
router
.route('/my-route')
.get(callBack)
.post(callBack)and so on.
I would also suggest separating your router from the controllers, and separating your API router from your client (views) router.
you could have a routers directory just like you have one for the controllers and export any routers you have from the index of that directory.
in the server, you would require the clientRouter and the apiRouter, where you can do app.use(clientRouter) and app.use('/api', apiRouter)
Metadata
Metadata
Assignees
Labels
No labels