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

Method getServer

packages/core/src/application.ts:246–258  ·  view source on GitHub ↗

* Retrieve the singleton instance for a bound server. * * @typeParam T - Server type * @param ctor - The constructor that was used to make the * binding. * @returns A Promise of server instance *

(
    target: Constructor<T> | string,
  )

Source from the content-addressed store, hash-verified

244 *
245 */
246 public async getServer<T extends Server>(
247 target: Constructor<T> | string,
248 ): Promise<T> {
249 let key: string;
250 // instanceof check not reliable for string.
251 if (typeof target === 'string') {
252 key = `${CoreBindings.SERVERS}.${target}`;
253 } else {
254 const ctor = target as Constructor<T>;
255 key = `${CoreBindings.SERVERS}.${ctor.name}`;
256 }
257 return this.get<T>(key);
258 }
259
260 /**
261 * Assert there is no other operation is in progress, i.e., the state is not

Callers 15

givenLoopBackAppFunction · 0.95
givenAServerFunction · 0.95
givenRequestContextFunction · 0.95
givenAServerFunction · 0.80
givenAServerFunction · 0.80
givenAServerFunction · 0.80
givenAServerFunction · 0.80
givenLoopBackAppFunction · 0.80
givenAServerFunction · 0.80

Calls 1

getMethod · 0.65

Tested by 15

givenLoopBackAppFunction · 0.76
givenAServerFunction · 0.76
givenRequestContextFunction · 0.76
givenAServerFunction · 0.64
givenAServerFunction · 0.64
givenAServerFunction · 0.64
givenAServerFunction · 0.64
givenLoopBackAppFunction · 0.64
givenAServerFunction · 0.64
givenApplicationFunction · 0.64
givenAnApplicationFunction · 0.64