Page Contents

Home > @loopback/rest > RestServer > mountExpressRouter

RestServer.mountExpressRouter() method

Mount an Express router to expose additional REST endpoints handled via legacy Express-based stack.

Signature:

mountExpressRouter(basePath: string, router: ExpressRequestHandler, spec?: RouterSpec): void;

Parameters

Parameter Type Description
basePath string Path where to mount the router at, e.g. `/` or `/api`.
router ExpressRequestHandler The Express router to handle the requests.
spec [RouterSpec](/doc/en/lb4/apidocs.rest.routerspec.html) _(Optional)_ A partial OpenAPI spec describing endpoints provided by the router. LoopBack will prepend `basePath` to all endpoints automatically. This argument is optional. You can leave it out if you don't want to document the routes.

Returns:

void