-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
This is a follow-up for the spike #2318, see the discussion and PoC code for more context.
Implement app.mountExpressRouter(basePath, router, spec?) to allow LB4 app developers to add arbitrary set of Express routes and provide OpenAPI spec
mountExpressRouter(
basePath: string,
router: ExpressRequestHandler,
spec?: RouterSpec,
): void;The new API should build on the foundation laid down by StaticAssetsRoute and allows LB4 app
developers to add arbitrary set of Express routes and provide OpenAPI spec.
As a result, LB4 will have the following request-handling pipeline:
- Request-preprocessing middleware like CORS, this is not customizable yet.
- Native LoopBack 4 routes (controller methods or route handlers).
- External Express routers (if the request was not handled yet).
- Static assets (if the request was not handled yet).
Related issues: #1849
Acceptance criteria
- Refactor
StaticAssetsRouteintoExternalExpressRoutesandExternalRoute, see PoC in external-express-routes.ts --> refactor(rest): rework StaticAssetsRoute into ExternalExpressRoutes #2524 - Add
mountExpressRouterto bothRestServerandRestApplicationclasses. - Update API docs
- Describe the new API in Routes, include a simple example based on
express.Router(not LB3).