@midwayjs/bootstrap 3.4.0-beta.1 → 3.4.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,13 +10,13 @@ export declare class BootstrapStarter {
10
10
  init(): Promise<IMidwayContainer>;
11
11
  run(): Promise<void>;
12
12
  stop(): Promise<void>;
13
+ getApplicationContext(): IMidwayContainer;
13
14
  protected getBaseDir(): string;
14
15
  }
15
16
  export declare class Bootstrap {
16
17
  private static starter;
17
18
  private static logger;
18
19
  private static configured;
19
- private static applicationContext;
20
20
  /**
21
21
  * set global configuration for midway
22
22
  * @param configuration
package/dist/bootstrap.js CHANGED
@@ -4,6 +4,7 @@ exports.Bootstrap = exports.BootstrapStarter = exports.isTypeScriptEnvironment =
4
4
  const core_1 = require("@midwayjs/core");
5
5
  const path_1 = require("path");
6
6
  const logger_1 = require("@midwayjs/logger");
7
+ const async_hooks_context_manager_1 = require("@midwayjs/async-hooks-context-manager");
7
8
  function isTypeScriptEnvironment() {
8
9
  const TS_MODE_PROCESS_FLAG = process.env.MIDWAY_TS_MODE;
9
10
  if ('false' === TS_MODE_PROCESS_FLAG) {
@@ -28,13 +29,19 @@ class BootstrapStarter {
28
29
  ...this.globalOptions,
29
30
  appDir: this.appDir,
30
31
  baseDir: this.baseDir,
32
+ asyncContextManager: (0, async_hooks_context_manager_1.createContextManager)(),
31
33
  });
32
34
  return this.applicationContext;
33
35
  }
34
- async run() { }
36
+ async run() {
37
+ this.applicationContext = await this.init();
38
+ }
35
39
  async stop() {
36
40
  await (0, core_1.destroyGlobalApplicationContext)(this.applicationContext);
37
41
  }
42
+ getApplicationContext() {
43
+ return this.applicationContext;
44
+ }
38
45
  getBaseDir() {
39
46
  if (this.globalOptions.baseDir) {
40
47
  return this.globalOptions.baseDir;
@@ -99,11 +106,11 @@ class Bootstrap {
99
106
  process.on('uncaughtException', this.uncaughtExceptionHandler);
100
107
  this.unhandledRejectionHandler = this.unhandledRejectionHandler.bind(this);
101
108
  process.on('unhandledRejection', this.unhandledRejectionHandler);
102
- this.applicationContext = await this.getStarter().init();
103
109
  return this.getStarter()
104
110
  .run()
105
111
  .then(() => {
106
112
  this.logger.info('[midway:bootstrap] current app started');
113
+ global['MIDWAY_BOOTSTRAP_APP_READY'] = true;
107
114
  })
108
115
  .catch(err => {
109
116
  this.logger.error(err);
@@ -115,6 +122,7 @@ class Bootstrap {
115
122
  process.removeListener('uncaughtException', this.uncaughtExceptionHandler);
116
123
  process.removeListener('unhandledRejection', this.unhandledRejectionHandler);
117
124
  this.reset();
125
+ global['MIDWAY_BOOTSTRAP_APP_READY'] = false;
118
126
  }
119
127
  static reset() {
120
128
  this.configured = false;
@@ -173,7 +181,7 @@ class Bootstrap {
173
181
  this.logger.error(err);
174
182
  }
175
183
  static getApplicationContext() {
176
- return this.applicationContext;
184
+ return this.getStarter().getApplicationContext();
177
185
  }
178
186
  }
179
187
  exports.Bootstrap = Bootstrap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/bootstrap",
3
- "version": "3.4.0-beta.1",
3
+ "version": "3.4.0-beta.12",
4
4
  "description": "midwayjs bootstrap",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -20,15 +20,17 @@
20
20
  "dist/**/*.d.ts"
21
21
  ],
22
22
  "license": "MIT",
23
+ "dependencies": {
24
+ "@midwayjs/async-hooks-context-manager": "^3.4.0-beta.12"
25
+ },
23
26
  "devDependencies": {
24
- "@midwayjs/core": "^3.4.0-beta.1",
25
- "@midwayjs/decorator": "^3.4.0-beta.1",
27
+ "@midwayjs/core": "^3.4.0-beta.12",
28
+ "@midwayjs/decorator": "^3.4.0-beta.12",
26
29
  "@midwayjs/logger": "^2.15.0",
27
- "@midwayjs/socketio": "^3.4.0-beta.1",
28
- "@midwayjs/web": "^3.4.0-beta.1",
29
- "@types/socket.io-client": "1.4.36",
30
+ "@midwayjs/socketio": "^3.4.0-beta.12",
31
+ "@midwayjs/web": "^3.4.0-beta.12",
30
32
  "request": "2.88.2",
31
- "socket.io-client": "4.4.1"
33
+ "socket.io-client": "4.5.1"
32
34
  },
33
35
  "author": "Harry Chen <czy88840616@gmail.com>",
34
36
  "repository": {
@@ -38,5 +40,5 @@
38
40
  "engines": {
39
41
  "node": ">=12"
40
42
  },
41
- "gitHead": "14d8440f20978426184c988808343cc24bcf6e20"
43
+ "gitHead": "cb639763ececfc7928221eaafbd515bfd93c6ca1"
42
44
  }