MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / constructor

Method constructor

packages/express/src/express.server.ts:53–77  ·  view source on GitHub ↗
(
    @inject(CoreBindings.APPLICATION_CONFIG.deepProperty('express'))
    protected readonly config?: ExpressServerConfig,
    @inject(CoreBindings.APPLICATION_INSTANCE)
    parent?: Context,
  )

Source from the content-addressed store, hash-verified

51 */
52 protected httpServer: HttpServer;
53 constructor(
54 @inject(CoreBindings.APPLICATION_CONFIG.deepProperty('express'))
55 protected readonly config?: ExpressServerConfig,
56 @inject(CoreBindings.APPLICATION_INSTANCE)
57 parent?: Context,
58 ) {
59 super(parent);
60 this.scope = BindingScope.SERVER;
61 let basePath = config?.basePath ?? '';
62 // Trim leading and trailing `/`
63 basePath = basePath.replace(/(^\/)|(\/$)/, '');
64 if (basePath) basePath = '/' + basePath;
65 this.basePath = basePath;
66
67 this.expressApp = express();
68 if (config?.settings) {
69 for (const p in config?.settings) {
70 this.expressApp.set(p, config?.settings[p]);
71 }
72 }
73 this.httpServer = new HttpServer(this.expressApp, config);
74
75 // Set up the middleware chain as the 1st Express middleware
76 this.expressApp.use(this.basePath, toExpressMiddleware(this));
77 }
78
79 /**
80 * Some of the methods below are copied from RestServer

Callers

nothing calls this directly

Calls 5

toExpressMiddlewareFunction · 0.90
injectFunction · 0.85
deepPropertyMethod · 0.80
setMethod · 0.65
useMethod · 0.65

Tested by

no test coverage detected