Story
As a LoopBack developer, I would like to have my RestServer provide static file hosting so that I can retrieve front-end content (HTML/CSS/JS).
(Additional note: This functionality would be required for an API Explorer Component)
Acceptance Criteria
Stretch goals:
Removed from scope by @bajtos on 2018-06-25:
Should default to /src/public
Should recursively map target directory's file and folder paths in memory (NOT THE CONTENT)
Story
As a LoopBack developer, I would like to have my RestServer provide static file hosting so that I can retrieve front-end content (HTML/CSS/JS).
(Additional note: This functionality would be required for an API Explorer Component)
Acceptance Criteria
RestServerandRestApplicationto allow app developers to mount static middleware, for exampleapp.static(path, options). Leverage Express middleware server-static to implement the actual file serving.Stretch goals:
Comment by @bajtos: Ideally, a LB4 app should have only one error handler responsible for handling all errors regardless of their source (controller methods, static middleware, input argument validation, etc.) To get there, we need to rethink and improve the error handling story in general, see The error response for a request with malformed JSON body provides too little information #1434. Unless we can find a way how to get nice 404 errors for static content with very little effort, I am proposing to defer this item and make it a part of The error response for a request with malformed JSON body provides too little information #1434.
Removed from scope by @bajtos on 2018-06-25:
Should default to/src/publicShould recursively map target directory's file and folder paths in memory (NOT THE CONTENT)