@midwayjs/web 3.1.1 → 3.1.4
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 +3 -0
- package/dist/framework/lifecycle.d.ts +1 -0
- package/dist/framework/lifecycle.js +3 -0
- package/dist/interface.d.ts +1 -1
- package/dist/utils.js +16 -11
- package/package.json +5 -5
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();
|
|
@@ -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
|
}
|
package/dist/interface.d.ts
CHANGED
|
@@ -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
|
|
89
|
+
interface MidwayConfig extends PowerPartial<EggAppConfig> {
|
|
90
90
|
egg?: IMidwayWebConfigurationOptions;
|
|
91
91
|
}
|
|
92
92
|
}
|
package/dist/utils.js
CHANGED
|
@@ -67,26 +67,38 @@ 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);
|
|
73
83
|
// init decorator service
|
|
74
84
|
const decoratorService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayDecoratorService);
|
|
85
|
+
const configService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayConfigService);
|
|
86
|
+
const loggerService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayLoggerService);
|
|
75
87
|
// framework/config/plugin/logger/app decorator support
|
|
76
88
|
// register base config hook
|
|
77
89
|
decoratorService.registerPropertyHandler(decorator_1.CONFIG_KEY, (propertyName, meta) => {
|
|
78
90
|
var _a;
|
|
79
91
|
if (meta.identifier === decorator_1.ALL) {
|
|
80
|
-
return
|
|
92
|
+
return configService.getConfiguration();
|
|
81
93
|
}
|
|
82
94
|
else {
|
|
83
|
-
return
|
|
95
|
+
return configService.getConfiguration((_a = meta.identifier) !== null && _a !== void 0 ? _a : propertyName);
|
|
84
96
|
}
|
|
85
97
|
});
|
|
86
98
|
// register @Logger decorator handler
|
|
87
99
|
decoratorService.registerPropertyHandler(decorator_1.LOGGER_KEY, (propertyName, meta) => {
|
|
88
100
|
var _a;
|
|
89
|
-
return
|
|
101
|
+
return loggerService.getLogger((_a = meta.identifier) !== null && _a !== void 0 ? _a : propertyName);
|
|
90
102
|
});
|
|
91
103
|
decoratorService.registerPropertyHandler(decorator_1.PIPELINE_IDENTIFIER, (key, meta, instance) => {
|
|
92
104
|
var _a, _b;
|
|
@@ -97,7 +109,7 @@ async function initializeAgentApplicationContext(agent) {
|
|
|
97
109
|
return agent;
|
|
98
110
|
});
|
|
99
111
|
decoratorService.registerPropertyHandler(decorator_1.PLUGIN_KEY, (key, target) => {
|
|
100
|
-
return
|
|
112
|
+
return agent[key];
|
|
101
113
|
});
|
|
102
114
|
// init aspect module
|
|
103
115
|
await aspectService.loadAspect();
|
|
@@ -106,13 +118,6 @@ async function initializeAgentApplicationContext(agent) {
|
|
|
106
118
|
else {
|
|
107
119
|
debug('[egg]: "initializeAgentApplicationContext" ignore re-init in single process');
|
|
108
120
|
}
|
|
109
|
-
const applicationContext = (0, core_1.getCurrentApplicationContext)();
|
|
110
|
-
const agentFramework = new web_1.MidwayWebFramework(applicationContext);
|
|
111
|
-
agentFramework['logger'] = agent.logger;
|
|
112
|
-
agentFramework['appLogger'] = agent.coreLogger;
|
|
113
|
-
agentFramework.app = agent;
|
|
114
|
-
agentFramework.configService = applicationContext.get(core_1.MidwayConfigService);
|
|
115
|
-
agentFramework.overwriteApplication('agent');
|
|
116
121
|
return applicationContext;
|
|
117
122
|
}
|
|
118
123
|
exports.initializeAgentApplicationContext = initializeAgentApplicationContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/web",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "Midway Web Framework for Egg.js",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@midwayjs/decorator": "^3.0.10",
|
|
31
31
|
"@midwayjs/logger": "^2.15.0",
|
|
32
|
-
"@midwayjs/mock": "^3.1.
|
|
33
|
-
"axios": "0.26.
|
|
32
|
+
"@midwayjs/mock": "^3.1.2",
|
|
33
|
+
"axios": "0.26.1",
|
|
34
34
|
"dayjs": "1.10.8",
|
|
35
35
|
"egg-logger": "2.7.1",
|
|
36
36
|
"egg-mock": "4.2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@eggjs/router": "^2.0.0",
|
|
49
|
-
"@midwayjs/core": "^3.1.
|
|
49
|
+
"@midwayjs/core": "^3.1.2",
|
|
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": "
|
|
63
|
+
"gitHead": "ca98130962ab629a65912870f82f64bd0e44566d"
|
|
64
64
|
}
|