Skip to content

Mount Express router with OpenAPI spec #2389

@bajtos

Description

@bajtos

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:

  1. Request-preprocessing middleware like CORS, this is not customizable yet.
  2. Native LoopBack 4 routes (controller methods or route handlers).
  3. External Express routers (if the request was not handled yet).
  4. Static assets (if the request was not handled yet).

Related issues: #1849

Acceptance criteria

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions