Page Contents
Home > @loopback/rest > RestApplication > expressMiddleware
RestApplication.expressMiddleware() method
Bind an Express middleware to this server context
Signature:
expressMiddleware<CFG>(middlewareFactory: ExpressMiddlewareFactory<CFG>, middlewareConfig?: CFG, options?: MiddlewareBindingOptions): Binding<Middleware>;
Parameters
Parameter | Type | Description |
---|---|---|
middlewareFactory | ExpressMiddlewareFactory<CFG> | Middleware module name or factory function |
middlewareConfig | CFG | (Optional) Middleware config |
options | MiddlewareBindingOptions | (Optional) Options for registration |
Returns:
Binding<Middleware>
Example
import myExpressMiddlewareFactory from 'my-express-middleware';
const myExpressMiddlewareConfig= {};
server.expressMiddleware(myExpressMiddlewareFactory, myExpressMiddlewareConfig);