@midwayjs/web 3.1.2 → 3.1.5

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.
package/app.js CHANGED
@@ -67,6 +67,9 @@ class AppBootHook {
67
67
  this.app.useMiddleware(eggRouterMiddleware);
68
68
 
69
69
  if (process.env['EGG_CLUSTER_MODE'] === 'true') {
70
+ const lifeCycleService = this.app.applicationContext.get('midwayWebLifeCycleService');
71
+ // exec onReady()
72
+ await lifeCycleService.runReady();
70
73
  // 多进程时的路由加载必须放在这里,中间件加载之后
71
74
  const framework = this.app.applicationContext.get('midwayWebFramework');
72
75
  await framework.loadMidwayController();
package/dist/cluster.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a, _b;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const core_1 = require("@midwayjs/core");
4
5
  const path_1 = require("path");
@@ -13,7 +14,7 @@ function runInAgent() {
13
14
  process.env['EGG_CLUSTER_MODE'] = 'true';
14
15
  const isAgent = runInAgent();
15
16
  debug('[egg]: run with egg-scripts in worker and init midway container in cluster mode');
16
- const appDir = process.cwd();
17
+ const appDir = (_b = (_a = JSON.parse(process.argv[2])) === null || _a === void 0 ? void 0 : _a.baseDir) !== null && _b !== void 0 ? _b : process.cwd();
17
18
  let baseDir;
18
19
  if ((0, utils_1.isTypeScriptEnvironment)()) {
19
20
  baseDir = (0, path_1.join)(appDir, 'src');
@@ -6,6 +6,7 @@ export declare class MidwayWebLifeCycleService {
6
6
  private lifecycleInstanceList;
7
7
  constructor(applicationContext: IMidwayContainer);
8
8
  protected init(): Promise<void>;
9
+ runReady(): Promise<void>;
9
10
  afterInit(): Promise<void>;
10
11
  stop(): Promise<void>;
11
12
  private runContainerLifeCycle;
@@ -53,6 +53,9 @@ let MidwayWebLifeCycleService = class MidwayWebLifeCycleService {
53
53
  this.configService.addObject(configData);
54
54
  }
55
55
  });
56
+ // cluster 下,onReady 放到 egg willReady 中执行
57
+ }
58
+ async runReady() {
56
59
  // exec onReady()
57
60
  await this.runContainerLifeCycle(this.lifecycleInstanceList, 'onReady');
58
61
  }
@@ -86,7 +86,7 @@ export interface IWebMiddleware {
86
86
  resolve(): MidwayWebMiddleware;
87
87
  }
88
88
  declare module '@midwayjs/core/dist/interface' {
89
- interface MidwayConfig extends Partial<EggAppConfig> {
89
+ interface MidwayConfig extends PowerPartial<EggAppConfig> {
90
90
  egg?: IMidwayWebConfigurationOptions;
91
91
  }
92
92
  }
package/dist/utils.js CHANGED
@@ -67,6 +67,16 @@ const getCurrentDateString = (timestamp = Date.now()) => {
67
67
  };
68
68
  exports.getCurrentDateString = getCurrentDateString;
69
69
  async function initializeAgentApplicationContext(agent) {
70
+ const applicationContext = (0, core_1.getCurrentApplicationContext)();
71
+ const agentFramework = new web_1.MidwayWebFramework(applicationContext);
72
+ agentFramework['logger'] = agent.logger;
73
+ agentFramework['appLogger'] = agent.coreLogger;
74
+ agentFramework.app = agent;
75
+ agentFramework.configService = applicationContext.get(core_1.MidwayConfigService);
76
+ agentFramework.environmentService = applicationContext.get(core_1.MidwayEnvironmentService);
77
+ agentFramework.loggerService = applicationContext.get(core_1.MidwayLoggerService);
78
+ agentFramework.informationService = applicationContext.get(core_1.MidwayInformationService);
79
+ agentFramework.overwriteApplication('agent');
70
80
  if (process.env['EGG_CLUSTER_MODE'] === 'true') {
71
81
  // init aop support
72
82
  const aspectService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayAspectService);
@@ -108,13 +118,6 @@ async function initializeAgentApplicationContext(agent) {
108
118
  else {
109
119
  debug('[egg]: "initializeAgentApplicationContext" ignore re-init in single process');
110
120
  }
111
- const applicationContext = (0, core_1.getCurrentApplicationContext)();
112
- const agentFramework = new web_1.MidwayWebFramework(applicationContext);
113
- agentFramework['logger'] = agent.logger;
114
- agentFramework['appLogger'] = agent.coreLogger;
115
- agentFramework.app = agent;
116
- agentFramework.configService = applicationContext.get(core_1.MidwayConfigService);
117
- agentFramework.overwriteApplication('agent');
118
121
  return applicationContext;
119
122
  }
120
123
  exports.initializeAgentApplicationContext = initializeAgentApplicationContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/web",
3
- "version": "3.1.2",
3
+ "version": "3.1.5",
4
4
  "description": "Midway Web Framework for Egg.js",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "devDependencies": {
30
30
  "@midwayjs/decorator": "^3.0.10",
31
31
  "@midwayjs/logger": "^2.15.0",
32
- "@midwayjs/mock": "^3.1.2",
32
+ "@midwayjs/mock": "^3.1.5",
33
33
  "axios": "0.26.1",
34
34
  "dayjs": "1.10.8",
35
35
  "egg-logger": "2.7.1",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@eggjs/router": "^2.0.0",
49
- "@midwayjs/core": "^3.1.2",
49
+ "@midwayjs/core": "^3.1.5",
50
50
  "egg": "^2.28.0",
51
51
  "egg-cluster": "^1.27.1",
52
52
  "find-up": "5.0.0",
@@ -60,5 +60,5 @@
60
60
  "engines": {
61
61
  "node": ">=12"
62
62
  },
63
- "gitHead": "4ff3aa892b76d016f0ea123c7f9520d054d5c96b"
63
+ "gitHead": "46a7851ad3ce6fc675bd7e1b7c9dff2c70009104"
64
64
  }