Skip to content

reorganize routes and controllers #5

@kapil1garg

Description

@kapil1garg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions