MCPcopy
hub / github.com/loopbackio/loopback-next / server

Method server

packages/core/src/application.ts:196–209  ·  view source on GitHub ↗

* Bind a Server constructor to the Application's master context. * Each server constructor added in this way must provide a unique prefix * to prevent binding overlap. * * @example * ```ts * app.server(RestServer); * // This server constructor will be bound under "servers.RestSe

(
    ctor: Constructor<T>,
    nameOrOptions?: string | BindingFromClassOptions,
  )

Source from the content-addressed store, hash-verified

194 *
195 */
196 public server<T extends Server>(
197 ctor: Constructor<T>,
198 nameOrOptions?: string | BindingFromClassOptions,
199 ): Binding<T> {
200 this.debug('Adding server %s', nameOrOptions ?? ctor.name);
201 const binding = createBindingFromClass(ctor, {
202 namespace: CoreBindings.SERVERS,
203 type: CoreTags.SERVER,
204 defaultScope: BindingScope.SINGLETON,
205 ...toOptions(nameOrOptions),
206 }).apply(asLifeCycleObserver);
207 this.add(binding);
208 return binding;
209 }
210
211 /**
212 * Bind an array of Server constructors to the Application's master

Callers 4

serversMethod · 0.95
mountComponentFunction · 0.45
constructorMethod · 0.45

Calls 5

createBindingFromClassFunction · 0.90
applyMethod · 0.80
toOptionsFunction · 0.70
addMethod · 0.65
debugMethod · 0.45

Tested by

no test coverage detected