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
I currently have routes based on broad parts of the network that other systems may want to access (e.g., info on people; info on projects; info on venues; etc.). As I've begun to add more routes to the API, each of these files has started to get chunky and harder to maintain since, for each route, I need (1) the request handler; and (2) a controller that fetches/formats the data.
An alternative architecture may look like this:
routes/api/
|_ index.js // combines all routes
|_people/
|____index.route.js // combines all routes in this directory
|____all.route.js // gets all people in community
|____faculty.route.js // gets all faculty members
|____phdstudents.route.js // gets all phd students
|____nonphdstudents.route.js // gets all non-phd students (i.e., MS and UGrad)
|____ ...
|
|__tools/
|____sprints/
|______sprintForPerson.route.js // gets the sprint log for a specific person
|______sprintForProj.route.js // gets the sprint log for a specific project
|
|__venues/
|
|__processes/
|
|__ ...
Within each of the leaf .js files, I could have the request hander and controller related to just the route there, and store any common controllers in controllers/. index.js files in each subdirectory setup the routes with a router and export the router so that routes/api/index.js can combine and export them to be added to the application.
I currently have routes based on broad parts of the network that other systems may want to access (e.g., info on people; info on projects; info on venues; etc.). As I've begun to add more routes to the API, each of these files has started to get chunky and harder to maintain since, for each route, I need (1) the request handler; and (2) a controller that fetches/formats the data.
An alternative architecture may look like this:
Within each of the leaf
.js
files, I could have the request hander and controller related to just the route there, and store any common controllers incontrollers/
.index.js
files in each subdirectory setup the routes with arouter
and export therouter
so thatroutes/api/index.js
can combine and export them to be added to the application.See here for an example.
The text was updated successfully, but these errors were encountered: