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
Application-wide route prefix management #11
Comments
Would adding router middleware to auto redirect on found mappings handle most cases? I guess there would still be the possibility for collisions. |
Also, this feels like it could very easily break everything unless everyone opts in. |
Yes, hard coded routes would be liable to break, everyone would need to use I don't think redirecting middleware helps the CAIT case where the app itself is mounted somewhere that is shared. Same issue, everyone would be expected to use realPath. |
Ok, good points. I think this is a fine solution then. |
Rather than modules all managing a "baseUrl" config and exposing that as a responder for other modules to retrieve and use in constructing sub-urls, provide a general mechanism for prefixing routes. In effect, routes become a namespace with known values (commonly based on module name) (
/admin/
,/users/
), and router handles where those actually respond.Proposal
Router config gets a
routePrefixes
key, with possible values like:These are all checked for initial matches to routes on startup when routes are actually registered with express, so this example would produce urls like:
And router provides helpers (responder and ejs) for finding the real value of a route for redirects or links:
The text was updated successfully, but these errors were encountered: