| 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 = |
| 124 | configOrParent instanceof Context ? {} : (configOrParent ?? {}); |
| 125 | |
| 126 | // Configure debug |
| 127 | this._debug = debug; |
| 128 | |
| 129 | // Bind the life cycle observer registry |
| 130 | this.bind(CoreBindings.LIFE_CYCLE_OBSERVER_REGISTRY) |
| 131 | .toClass(LifeCycleObserverRegistry) |
| 132 | .inScope(BindingScope.SINGLETON); |
| 133 | // Bind to self to allow injection of application context in other modules. |
| 134 | this.bind(CoreBindings.APPLICATION_INSTANCE).to(this); |
| 135 | // Make options available to other modules as well. |
| 136 | this.bind(CoreBindings.APPLICATION_CONFIG).to(this.options); |
| 137 | |
| 138 | // Also configure the application instance to allow `@config` |
| 139 | this.configure(CoreBindings.APPLICATION_INSTANCE).toAlias( |
| 140 | CoreBindings.APPLICATION_CONFIG, |
| 141 | ); |
| 142 | |
| 143 | this._shutdownOptions = {signals: ['SIGTERM'], ...this.options.shutdown}; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Register a controller class with this application. |