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

Class Application

packages/core/src/application.ts:66–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 * and models.
65 */
66export class Application extends Context implements LifeCycleObserver {
67 public readonly options: ApplicationConfig;
68
69 /**
70 * A flag to indicate that the application is being shut down
71 */
72 private _isShuttingDown = false;
73 private _shutdownOptions: ShutdownOptions;
74 private _signalListener: (signal: string) => Promise<void>;
75
76 private _initialized = false;
77
78 /**
79 * State of the application
80 */
81 private _state = 'created';
82
83 /**
84 * Get the state of the application. The initial state is `created` and it can
85 * transition as follows by `start` and `stop`:
86 *
87 * 1. start
88 * - !started -> starting -> started
89 * - started -> started (no-op)
90 * 2. stop
91 * - (started | initialized) -> stopping -> stopped
92 * - ! (started || initialized) -> stopped (no-op)
93 *
94 * Two types of states are expected:
95 * - stable, such as `started` and `stopped`
96 * - in process, such as `booting` and `starting`
97 *
98 * Operations such as `start` and `stop` can only be called at a stable state.
99 * The logic should immediately set the state to a new one indicating work in
100 * process, such as `starting` and `stopping`.
101 */
102 public get state() {
103 return this._state;
104 }
105
106 /**
107 * Create an application with the given parent context
108 * @param parent - Parent context
109 */
110 constructor(parent: Context);
111 /**
112 * Create an application with the given configuration and parent context
113 * @param config - Application configuration
114 * @param parent - Parent context
115 */
116 constructor(config?: ApplicationConfig, parent?: Context);
117
118 constructor(configOrParent?: ApplicationConfig | Context, parent?: Context) {
119 // super() has to be first statement for a constructor
120 super(...buildConstructorArgs(configOrParent, parent));
121 this.scope = BindingScope.APPLICATION;
122
123 this.options =

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected