@midwayjs/web 3.0.0-alpha.43 → 3.0.0-beta.10
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/CHANGELOG.md +115 -0
- package/README.md +1 -1
- package/agent.js +13 -6
- package/app/extend/agent.js +0 -4
- package/app/extend/application.js +0 -4
- package/app.js +17 -18
- package/config/config.default.js +13 -8
- package/config/plugin.js +6 -4
- package/dist/base.js +70 -44
- package/dist/configuration.d.ts +13 -0
- package/dist/configuration.js +102 -0
- package/dist/framework/web.d.ts +25 -26
- package/dist/framework/web.js +191 -118
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/interface.d.ts +53 -12
- package/dist/logger.d.ts +35 -2
- package/dist/logger.js +78 -96
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +126 -3
- package/package.json +11 -15
- package/dist/framework/singleProcess.d.ts +0 -34
- package/dist/framework/singleProcess.js +0 -132
- package/dist/starter.d.ts +0 -12
- package/dist/starter.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,121 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* default add session & bodyparser support for koa/express/faas ([#1420](https://github.com/midwayjs/midway/issues/1420)) ([cdaff31](https://github.com/midwayjs/midway/commit/cdaff317c3e862a95494a167995a28280af639bf))
|
|
12
|
+
* implement i18n for validate ([#1426](https://github.com/midwayjs/midway/issues/1426)) ([4c7ed2f](https://github.com/midwayjs/midway/commit/4c7ed2ff2e7ccf10f88f62abad230f92f5e76b97))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [3.0.0-beta.9](https://github.com/midwayjs/midway/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-12-09)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @midwayjs/web
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* express routing middleware takes effect at the controller level ([#1364](https://github.com/midwayjs/midway/issues/1364)) ([b9272e0](https://github.com/midwayjs/midway/commit/b9272e0971003443304b0c53815be31a0061b4bd))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* middleware with ctx.body ([#1389](https://github.com/midwayjs/midway/issues/1389)) ([77af5c0](https://github.com/midwayjs/midway/commit/77af5c0b456f1843f4dcfd3dbfd2c0aa244c51bd))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* class transformer method missing ([#1387](https://github.com/midwayjs/midway/issues/1387)) ([074e839](https://github.com/midwayjs/midway/commit/074e8393598dc95e2742f735df75a2191c5fe25d))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
|
|
60
|
+
|
|
61
|
+
**Note:** Version bump only for package @midwayjs/web
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
* logger close before bootstrap close ([#1370](https://github.com/midwayjs/midway/issues/1370)) ([6cc2720](https://github.com/midwayjs/midway/commit/6cc2720ed3445e8ffccc96d124b80ed7e2517f08))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Features
|
|
76
|
+
|
|
77
|
+
* add i18n ([#1375](https://github.com/midwayjs/midway/issues/1375)) ([bffefe0](https://github.com/midwayjs/midway/commit/bffefe07afe45777d49b5a76b9ab17fc2b9d9a55))
|
|
78
|
+
* auto transform args to type ([#1372](https://github.com/midwayjs/midway/issues/1372)) ([bb3f7d2](https://github.com/midwayjs/midway/commit/bb3f7d2028a034e1926d9df554849332354c3762))
|
|
79
|
+
* support global prefix url ([#1371](https://github.com/midwayjs/midway/issues/1371)) ([cc5fe44](https://github.com/midwayjs/midway/commit/cc5fe44e1d221590562dc71e1f33ae96093e0da7))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
* add component and framework config definition ([#1367](https://github.com/midwayjs/midway/issues/1367)) ([b2fe615](https://github.com/midwayjs/midway/commit/b2fe6157f99659471ff1333eca0b86bb889f61a3))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
|
|
97
|
+
|
|
98
|
+
**Note:** Version bump only for package @midwayjs/web
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Bug Fixes
|
|
108
|
+
|
|
109
|
+
* find egg plugin in cwd ([#1236](https://github.com/midwayjs/midway/issues/1236)) ([d9ac0ff](https://github.com/midwayjs/midway/commit/d9ac0ff6d4e7a58a8924636806d3894acf94fcd8))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Features
|
|
113
|
+
|
|
114
|
+
* add http2 support ([#1242](https://github.com/midwayjs/midway/issues/1242)) ([6cda27e](https://github.com/midwayjs/midway/commit/6cda27e9e22689e46ace543326b43ae21b134911))
|
|
115
|
+
* add view, view-ejs and view-nunjucks ([#1308](https://github.com/midwayjs/midway/issues/1308)) ([a00f44b](https://github.com/midwayjs/midway/commit/a00f44bd769052245cd49d49ab417d621bb89caa))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
6
121
|
## [2.12.3](https://github.com/midwayjs/midway/compare/v2.12.2...v2.12.3) (2021-08-09)
|
|
7
122
|
|
|
8
123
|
|
package/README.md
CHANGED
package/agent.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const { debuglog } = require('util');
|
|
3
|
+
const debug = debuglog('midway:debug');
|
|
2
4
|
|
|
3
5
|
class AgentBootHook {
|
|
4
6
|
constructor(app) {
|
|
@@ -6,15 +8,20 @@ class AgentBootHook {
|
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
configDidLoad() {
|
|
9
|
-
|
|
10
|
-
// if use midway logger will be use midway custom context logger
|
|
11
|
-
this.app.ContextLogger = this.app.webFramework.BaseContextLoggerClass;
|
|
12
|
-
}
|
|
11
|
+
debug('[egg:lifecycle]: agent configDidLoad');
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
async didLoad() {
|
|
14
|
+
async didLoad() {
|
|
15
|
+
debug('[egg:lifecycle]: agent didLoad');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async willReady() {
|
|
19
|
+
debug('[egg:lifecycle]: agent willReady');
|
|
20
|
+
}
|
|
16
21
|
|
|
17
|
-
async
|
|
22
|
+
async beforeClose() {
|
|
23
|
+
debug('[egg:lifecycle]: agent beforeClose');
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
module.exports = AgentBootHook;
|
package/app/extend/agent.js
CHANGED
package/app.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const pathMatching = require('egg-path-matching');
|
|
4
|
-
const {
|
|
4
|
+
const { debuglog } = require('util');
|
|
5
|
+
|
|
6
|
+
const debug = debuglog('midway:debug');
|
|
5
7
|
|
|
6
8
|
class AppBootHook {
|
|
7
9
|
constructor(app) {
|
|
@@ -11,35 +13,30 @@ class AppBootHook {
|
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
configDidLoad() {
|
|
16
|
+
debug('[egg lifecycle]: app configDidLoad');
|
|
14
17
|
// 先清空,防止加载到 midway 中间件出错
|
|
15
18
|
this.coreMiddleware = this.app.loader.config.coreMiddleware;
|
|
16
19
|
this.app.loader.config.coreMiddleware = [];
|
|
17
20
|
this.appMiddleware = this.app.loader.config.appMiddleware;
|
|
18
21
|
this.app.loader.config.appMiddleware = [];
|
|
19
|
-
if (this.app.config.midwayFeature['replaceEggLogger']) {
|
|
20
|
-
// if use midway logger will be use midway custom context logger
|
|
21
|
-
this.app.ContextLogger = this.app.webFramework.BaseContextLoggerClass;
|
|
22
|
-
}
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
async didLoad() {
|
|
25
|
+
debug('[egg lifecycle]: app didLoad');
|
|
26
26
|
if (this.app.loader['useEggSocketIO']) {
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
27
|
+
// egg socket.io 需要这个中间件
|
|
28
|
+
// const session = this.app.getMiddleware().findItem('session');
|
|
29
|
+
// this.app.middleware.push(session);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
async willReady() {
|
|
35
|
-
|
|
34
|
+
debug('[egg lifecycle]: app willReady');
|
|
36
35
|
const middlewareNames = this.coreMiddleware.concat(this.appMiddleware);
|
|
37
36
|
// 等 midway 加载完成后,再去 use 中间件
|
|
38
37
|
for (const name of middlewareNames) {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
mwIns._name = name;
|
|
42
|
-
this.app.use(mwIns);
|
|
38
|
+
if (this.app.getApplicationContext().registry.hasDefinition(name)) {
|
|
39
|
+
await this.app.useMiddleware(name);
|
|
43
40
|
} else {
|
|
44
41
|
// egg
|
|
45
42
|
const options = this.app.config[name] || {};
|
|
@@ -60,17 +57,19 @@ class AppBootHook {
|
|
|
60
57
|
return mw(ctx, next);
|
|
61
58
|
};
|
|
62
59
|
fn._name = mw._name + 'middlewareWrapper';
|
|
63
|
-
this.app.
|
|
60
|
+
await this.app.useMiddleware(fn);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
this.app.
|
|
69
|
-
|
|
65
|
+
const eggRouterMiddleware = this.app.router.middleware();
|
|
66
|
+
eggRouterMiddleware._name = 'eggRouterMiddleware';
|
|
67
|
+
this.app.useMiddleware(eggRouterMiddleware);
|
|
68
|
+
this.app.emit('application-ready');
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
async beforeClose() {
|
|
73
|
-
|
|
72
|
+
debug('[egg lifecycle]: app beforeClose');
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
package/config/config.default.js
CHANGED
|
@@ -11,14 +11,19 @@ module.exports = appInfo => {
|
|
|
11
11
|
exports.rundir = path.join(appInfo.appDir, 'run');
|
|
12
12
|
|
|
13
13
|
// 修改默认的日志名
|
|
14
|
-
exports.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
exports.midwayLogger = {
|
|
15
|
+
clients: {
|
|
16
|
+
coreLogger: {
|
|
17
|
+
fileLogName: 'midway-core.log',
|
|
18
|
+
},
|
|
19
|
+
appLogger: {
|
|
20
|
+
fileLogName: 'midway-web.log',
|
|
21
|
+
aliasName: 'logger',
|
|
22
|
+
},
|
|
23
|
+
agentLogger: {
|
|
24
|
+
fileLogName: 'midway-agent.log',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
exports.pluginOverwrite = false;
|
package/config/plugin.js
CHANGED
|
@@ -4,8 +4,10 @@ module.exports = {
|
|
|
4
4
|
static: false,
|
|
5
5
|
development: false,
|
|
6
6
|
watcher: false,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
onerror: true,
|
|
8
|
+
multipart: true,
|
|
9
|
+
security: true,
|
|
10
|
+
logrotator: false,
|
|
11
|
+
view: false,
|
|
12
|
+
schedule: false,
|
|
11
13
|
};
|
package/dist/base.js
CHANGED
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createEggAgent = exports.createEggApplication = exports.createAgentWorkerLoader = exports.createAppWorkerLoader = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
const extend = require("extend2");
|
|
6
|
-
const web_1 = require("./framework/web");
|
|
7
6
|
const core_1 = require("@midwayjs/core");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const fs_1 = require("fs");
|
|
10
9
|
const logger_1 = require("./logger");
|
|
11
10
|
const router_1 = require("@eggjs/router");
|
|
12
|
-
const
|
|
11
|
+
const util_1 = require("util");
|
|
13
12
|
const ROUTER = Symbol('EggCore#router');
|
|
14
13
|
const EGG_LOADER = Symbol.for('egg#loader');
|
|
15
14
|
const EGG_PATH = Symbol.for('egg#eggPath');
|
|
16
15
|
const LOGGERS = Symbol('EggApplication#loggers');
|
|
16
|
+
const debug = (0, util_1.debuglog)('midway:debug');
|
|
17
17
|
let customFramework = null;
|
|
18
18
|
function getFramework() {
|
|
19
19
|
if (customFramework)
|
|
@@ -39,6 +39,9 @@ const createAppWorkerLoader = () => {
|
|
|
39
39
|
this.useEggSocketIO = false;
|
|
40
40
|
}
|
|
41
41
|
getEggPaths() {
|
|
42
|
+
if ((0, core_1.getCurrentApplicationContext)()) {
|
|
43
|
+
this.singleProcessMode = true;
|
|
44
|
+
}
|
|
42
45
|
if (!this.appDir) {
|
|
43
46
|
// 这里的逻辑是为了兼容老 cluster 模式
|
|
44
47
|
if (this.app.options.typescript || this.app.options.isTsMode) {
|
|
@@ -102,35 +105,37 @@ const createAppWorkerLoader = () => {
|
|
|
102
105
|
return serverEnv;
|
|
103
106
|
}
|
|
104
107
|
load() {
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.
|
|
116
|
-
|
|
117
|
-
})
|
|
118
|
-
.load(this.framework);
|
|
119
|
-
if (this.app.options['midwaySingleton'] !== true) {
|
|
120
|
-
// 这个代码只会在 egg-cluster 模式下执行
|
|
121
|
-
this.app.beforeStart(async () => {
|
|
122
|
-
await this.bootstrap.init();
|
|
123
|
-
super.load();
|
|
108
|
+
if (!this.singleProcessMode) {
|
|
109
|
+
// 多进程模式,从 egg-scripts 启动的
|
|
110
|
+
process.env['EGG_CLUSTER_MODE'] = 'true';
|
|
111
|
+
debug('[egg]: run with egg-scripts in cluster mode');
|
|
112
|
+
// 如果不走 bootstrap,就得在这里初始化 applicationContext
|
|
113
|
+
(0, core_1.initializeGlobalApplicationContext)({
|
|
114
|
+
...this.globalOptions,
|
|
115
|
+
appDir: this.appDir,
|
|
116
|
+
baseDir: this.baseDir,
|
|
117
|
+
ignore: ['**/app/extend/**'],
|
|
118
|
+
}).then(r => {
|
|
119
|
+
debug('[egg]: global context: init complete');
|
|
124
120
|
});
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
async loadOrigin() {
|
|
131
|
-
await this.bootstrap.init();
|
|
123
|
+
loadOrigin() {
|
|
124
|
+
debug('[egg]: application: run load()');
|
|
132
125
|
super.load();
|
|
133
126
|
}
|
|
127
|
+
loadConfig() {
|
|
128
|
+
super.loadConfig();
|
|
129
|
+
if (this.singleProcessMode) {
|
|
130
|
+
const configService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayConfigService);
|
|
131
|
+
configService.addObject(this.config);
|
|
132
|
+
Object.defineProperty(this, 'config', {
|
|
133
|
+
get() {
|
|
134
|
+
return configService.getConfiguration();
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
134
139
|
loadMiddleware() {
|
|
135
140
|
super.loadMiddleware();
|
|
136
141
|
if (this.plugins['io']) {
|
|
@@ -148,8 +153,11 @@ const createAgentWorkerLoader = () => {
|
|
|
148
153
|
var _a;
|
|
149
154
|
const AppWorkerLoader = ((_a = require(getFramework())) === null || _a === void 0 ? void 0 : _a.AgentWorkerLoader) ||
|
|
150
155
|
require('egg').AgentWorkerLoader;
|
|
151
|
-
class
|
|
156
|
+
class EggAgentWorkerLoader extends AppWorkerLoader {
|
|
152
157
|
getEggPaths() {
|
|
158
|
+
if ((0, core_1.getCurrentApplicationContext)()) {
|
|
159
|
+
this.singleProcessMode = true;
|
|
160
|
+
}
|
|
153
161
|
if (!this.appDir) {
|
|
154
162
|
if (this.app.options.typescript || this.app.options.isTsMode) {
|
|
155
163
|
process.env.EGG_TYPESCRIPT = 'true';
|
|
@@ -212,26 +220,32 @@ const createAgentWorkerLoader = () => {
|
|
|
212
220
|
return serverEnv;
|
|
213
221
|
}
|
|
214
222
|
load() {
|
|
215
|
-
this.framework = new web_1.MidwayWebFramework().configure({
|
|
216
|
-
processType: 'agent',
|
|
217
|
-
app: this.app,
|
|
218
|
-
globalConfig: this.app.config,
|
|
219
|
-
});
|
|
220
|
-
this.bootstrap = new starter_1.WebBootstrapStarter({
|
|
221
|
-
isWorker: false,
|
|
222
|
-
});
|
|
223
|
-
this.bootstrap
|
|
224
|
-
.configure({
|
|
225
|
-
appDir: this.app.appDir,
|
|
226
|
-
})
|
|
227
|
-
.load(this.framework);
|
|
228
223
|
this.app.beforeStart(async () => {
|
|
229
|
-
|
|
224
|
+
debug('[egg]: start "initializeAgentApplicationContext"');
|
|
225
|
+
await (0, utils_1.initializeAgentApplicationContext)(this.app, {
|
|
226
|
+
...this.globalOptions,
|
|
227
|
+
appDir: this.appDir,
|
|
228
|
+
baseDir: this.baseDir,
|
|
229
|
+
ignore: ['**/app/extend/**'],
|
|
230
|
+
});
|
|
230
231
|
super.load();
|
|
232
|
+
debug('[egg]: agent load run complete');
|
|
231
233
|
});
|
|
232
234
|
}
|
|
235
|
+
loadConfig() {
|
|
236
|
+
super.loadConfig();
|
|
237
|
+
if (this.singleProcessMode) {
|
|
238
|
+
const configService = (0, core_1.getCurrentApplicationContext)().get(core_1.MidwayConfigService);
|
|
239
|
+
configService.addObject(this.config);
|
|
240
|
+
Object.defineProperty(this, 'config', {
|
|
241
|
+
get() {
|
|
242
|
+
return configService.getConfiguration();
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
233
247
|
}
|
|
234
|
-
return
|
|
248
|
+
return EggAgentWorkerLoader;
|
|
235
249
|
};
|
|
236
250
|
exports.createAgentWorkerLoader = createAgentWorkerLoader;
|
|
237
251
|
const createEggApplication = () => {
|
|
@@ -250,7 +264,7 @@ const createEggApplication = () => {
|
|
|
250
264
|
}
|
|
251
265
|
get loggers() {
|
|
252
266
|
if (!this[LOGGERS]) {
|
|
253
|
-
this[LOGGERS] = (0, logger_1.createLoggers)(this);
|
|
267
|
+
this[LOGGERS] = (0, logger_1.createLoggers)(this, 'app');
|
|
254
268
|
}
|
|
255
269
|
return this[LOGGERS];
|
|
256
270
|
}
|
|
@@ -261,6 +275,12 @@ const createEggApplication = () => {
|
|
|
261
275
|
const router = (this[ROUTER] = new router_1.EggRouter({ sensitive: true }, this));
|
|
262
276
|
return router;
|
|
263
277
|
}
|
|
278
|
+
dumpConfig() {
|
|
279
|
+
var _a, _b;
|
|
280
|
+
if (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.egg) === null || _b === void 0 ? void 0 : _b.dumpConfig) !== false) {
|
|
281
|
+
super.dumpConfig();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
264
284
|
}
|
|
265
285
|
return EggApplication;
|
|
266
286
|
};
|
|
@@ -281,10 +301,16 @@ const createEggAgent = () => {
|
|
|
281
301
|
}
|
|
282
302
|
get loggers() {
|
|
283
303
|
if (!this[LOGGERS]) {
|
|
284
|
-
this[LOGGERS] = (0, logger_1.createLoggers)(this);
|
|
304
|
+
this[LOGGERS] = (0, logger_1.createLoggers)(this, 'agent');
|
|
285
305
|
}
|
|
286
306
|
return this[LOGGERS];
|
|
287
307
|
}
|
|
308
|
+
dumpConfig() {
|
|
309
|
+
var _a, _b;
|
|
310
|
+
if (((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.egg) === null || _b === void 0 ? void 0 : _b.dumpConfig) !== false) {
|
|
311
|
+
super.dumpConfig();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
288
314
|
}
|
|
289
315
|
return EggAgent;
|
|
290
316
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IMidwayWebApplication } from './interface';
|
|
2
|
+
import { MidwayDecoratorService } from '@midwayjs/core';
|
|
3
|
+
export declare class EggConfiguration {
|
|
4
|
+
baseDir: any;
|
|
5
|
+
appDir: any;
|
|
6
|
+
app: IMidwayWebApplication;
|
|
7
|
+
decoratorService: MidwayDecoratorService;
|
|
8
|
+
init(): void;
|
|
9
|
+
onReady(): Promise<void>;
|
|
10
|
+
onServerReady(): Promise<void>;
|
|
11
|
+
onStop(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EggConfiguration = void 0;
|
|
13
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
+
const core_1 = require("@midwayjs/core");
|
|
15
|
+
let EggConfiguration = class EggConfiguration {
|
|
16
|
+
init() {
|
|
17
|
+
this.decoratorService.registerParameterHandler(decorator_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
18
|
+
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async onReady() {
|
|
22
|
+
// ps: 本想在这里清理掉egg添加的中间件,但是这里的数组已经只有一个 midway root middleware,其他的 getter 都是 egg 加进去的,但是不会被中间件执行,所以不需要清理
|
|
23
|
+
// 去掉为了 egg-socket.io 报错扫进去的 session
|
|
24
|
+
this.app.middleware = this.app.middleware.slice(0);
|
|
25
|
+
}
|
|
26
|
+
async onServerReady() {
|
|
27
|
+
// trigger server didReady
|
|
28
|
+
this.app.messenger.emit('egg-ready');
|
|
29
|
+
}
|
|
30
|
+
async onStop() {
|
|
31
|
+
// TODO flush egg logger and close it
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, decorator_1.Inject)(),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], EggConfiguration.prototype, "baseDir", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, decorator_1.Inject)(),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], EggConfiguration.prototype, "appDir", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, decorator_1.App)(),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], EggConfiguration.prototype, "app", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, decorator_1.Inject)(),
|
|
48
|
+
__metadata("design:type", core_1.MidwayDecoratorService)
|
|
49
|
+
], EggConfiguration.prototype, "decoratorService", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, decorator_1.Init)(),
|
|
52
|
+
__metadata("design:type", Function),
|
|
53
|
+
__metadata("design:paramtypes", []),
|
|
54
|
+
__metadata("design:returntype", void 0)
|
|
55
|
+
], EggConfiguration.prototype, "init", null);
|
|
56
|
+
EggConfiguration = __decorate([
|
|
57
|
+
(0, decorator_1.Configuration)({
|
|
58
|
+
namespace: 'egg',
|
|
59
|
+
importConfigs: [
|
|
60
|
+
{
|
|
61
|
+
default: {
|
|
62
|
+
midwayLogger: {
|
|
63
|
+
clients: {
|
|
64
|
+
appLogger: {
|
|
65
|
+
fileLogName: 'midway-web.log',
|
|
66
|
+
aliasName: 'logger',
|
|
67
|
+
},
|
|
68
|
+
agentLogger: {
|
|
69
|
+
fileLogName: 'midway-agent.log',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
egg: {
|
|
74
|
+
dumpConfig: true,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
test: {
|
|
78
|
+
egg: {
|
|
79
|
+
plugins: {
|
|
80
|
+
'egg-mock': {
|
|
81
|
+
enable: true,
|
|
82
|
+
package: 'egg-mock',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
unittest: {
|
|
88
|
+
egg: {
|
|
89
|
+
plugins: {
|
|
90
|
+
'egg-mock': {
|
|
91
|
+
enable: true,
|
|
92
|
+
package: 'egg-mock',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
})
|
|
100
|
+
], EggConfiguration);
|
|
101
|
+
exports.EggConfiguration = EggConfiguration;
|
|
102
|
+
//# sourceMappingURL=configuration.js.map
|