Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize routes and controllers #5

Open
kapil1garg opened this issue Jan 21, 2022 · 0 comments
Open

reorganize routes and controllers #5

kapil1garg opened this issue Jan 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@kapil1garg
Copy link
Contributor

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.

See here for an example.

@kapil1garg kapil1garg added the enhancement New feature or request label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant