@midwayjs/web 3.0.0-beta.1 → 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 +98 -0
- package/README.md +1 -1
- package/app.js +3 -4
- package/dist/configuration.d.ts +1 -3
- package/dist/configuration.js +6 -8
- package/dist/framework/web.d.ts +10 -2
- package/dist/framework/web.js +58 -50
- package/dist/interface.d.ts +27 -10
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,104 @@
|
|
|
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
|
+
|
|
6
104
|
# [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
|
|
7
105
|
|
|
8
106
|
|
package/README.md
CHANGED
package/app.js
CHANGED
|
@@ -24,10 +24,9 @@ class AppBootHook {
|
|
|
24
24
|
async didLoad() {
|
|
25
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
|
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { IMidwayWebApplication } from './interface';
|
|
2
|
-
import { MidwayWebFramework } from './framework/web';
|
|
3
2
|
import { MidwayDecoratorService } from '@midwayjs/core';
|
|
4
3
|
export declare class EggConfiguration {
|
|
5
4
|
baseDir: any;
|
|
6
5
|
appDir: any;
|
|
7
6
|
app: IMidwayWebApplication;
|
|
8
|
-
webFramework: MidwayWebFramework;
|
|
9
7
|
decoratorService: MidwayDecoratorService;
|
|
10
8
|
init(): void;
|
|
11
|
-
onReady(
|
|
9
|
+
onReady(): Promise<void>;
|
|
12
10
|
onServerReady(): Promise<void>;
|
|
13
11
|
onStop(): Promise<void>;
|
|
14
12
|
}
|
package/dist/configuration.js
CHANGED
|
@@ -11,18 +11,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EggConfiguration = void 0;
|
|
13
13
|
const decorator_1 = require("@midwayjs/decorator");
|
|
14
|
-
const web_1 = require("./framework/web");
|
|
15
14
|
const core_1 = require("@midwayjs/core");
|
|
16
15
|
let EggConfiguration = class EggConfiguration {
|
|
17
16
|
init() {
|
|
18
17
|
this.decoratorService.registerParameterHandler(decorator_1.WEB_ROUTER_PARAM_KEY, options => {
|
|
19
|
-
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData)(options.originArgs[0], options.originArgs[1]);
|
|
18
|
+
return (0, core_1.extractKoaLikeValue)(options.metadata.type, options.metadata.propertyData, options.originParamType)(options.originArgs[0], options.originArgs[1]);
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
async onReady(
|
|
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
|
+
}
|
|
23
26
|
async onServerReady() {
|
|
24
27
|
// trigger server didReady
|
|
25
|
-
await this.webFramework.run();
|
|
26
28
|
this.app.messenger.emit('egg-ready');
|
|
27
29
|
}
|
|
28
30
|
async onStop() {
|
|
@@ -41,10 +43,6 @@ __decorate([
|
|
|
41
43
|
(0, decorator_1.App)(),
|
|
42
44
|
__metadata("design:type", Object)
|
|
43
45
|
], EggConfiguration.prototype, "app", void 0);
|
|
44
|
-
__decorate([
|
|
45
|
-
(0, decorator_1.Inject)(),
|
|
46
|
-
__metadata("design:type", web_1.MidwayWebFramework)
|
|
47
|
-
], EggConfiguration.prototype, "webFramework", void 0);
|
|
48
46
|
__decorate([
|
|
49
47
|
(0, decorator_1.Inject)(),
|
|
50
48
|
__metadata("design:type", core_1.MidwayDecoratorService)
|
package/dist/framework/web.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { BaseFramework, IMidwayBootstrapOptions } from '@midwayjs/core';
|
|
1
|
+
import { BaseFramework, IMidwayBootstrapOptions, RouterInfo, WebControllerGenerator } from '@midwayjs/core';
|
|
2
2
|
import { MidwayFrameworkType } from '@midwayjs/decorator';
|
|
3
3
|
import { IMidwayWebConfigurationOptions } from '../interface';
|
|
4
|
+
import { EggRouter } from '@eggjs/router';
|
|
4
5
|
import { Application, Context, EggLogger } from 'egg';
|
|
6
|
+
declare class EggControllerGenerator extends WebControllerGenerator<EggRouter> {
|
|
7
|
+
readonly app: any;
|
|
8
|
+
constructor(app: any);
|
|
9
|
+
createRouter(routerOptions: any): EggRouter;
|
|
10
|
+
generateController(routeInfo: RouterInfo): (ctx: any, next: any) => Promise<void>;
|
|
11
|
+
}
|
|
5
12
|
export declare class MidwayWebFramework extends BaseFramework<Application, Context, IMidwayWebConfigurationOptions> {
|
|
6
13
|
protected loggers: {
|
|
7
14
|
[name: string]: EggLogger;
|
|
8
15
|
};
|
|
9
|
-
generator:
|
|
16
|
+
generator: EggControllerGenerator;
|
|
10
17
|
private server;
|
|
11
18
|
private agent;
|
|
12
19
|
private isClusterMode;
|
|
@@ -23,4 +30,5 @@ export declare class MidwayWebFramework extends BaseFramework<Application, Conte
|
|
|
23
30
|
generateMiddleware(middlewareId: string): Promise<any>;
|
|
24
31
|
beforeStop(): Promise<void>;
|
|
25
32
|
}
|
|
33
|
+
export {};
|
|
26
34
|
//# sourceMappingURL=web.d.ts.map
|
package/dist/framework/web.js
CHANGED
|
@@ -19,19 +19,17 @@ const util_1 = require("util");
|
|
|
19
19
|
const logger_2 = require("../logger");
|
|
20
20
|
const debug = (0, util_1.debuglog)('midway:debug');
|
|
21
21
|
class EggControllerGenerator extends core_1.WebControllerGenerator {
|
|
22
|
-
constructor(app
|
|
23
|
-
super(
|
|
22
|
+
constructor(app) {
|
|
23
|
+
super(app);
|
|
24
24
|
this.app = app;
|
|
25
|
-
this.applicationContext = applicationContext;
|
|
26
|
-
this.logger = logger;
|
|
27
25
|
}
|
|
28
26
|
createRouter(routerOptions) {
|
|
29
27
|
const router = new router_1.EggRouter(routerOptions, this.app);
|
|
30
28
|
router.prefix(routerOptions.prefix);
|
|
31
29
|
return router;
|
|
32
30
|
}
|
|
33
|
-
generateController(
|
|
34
|
-
return this.generateKoaController(
|
|
31
|
+
generateController(routeInfo) {
|
|
32
|
+
return this.generateKoaController(routeInfo);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
@@ -66,43 +64,18 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
66
64
|
application.agent = agent;
|
|
67
65
|
agent.application = application;
|
|
68
66
|
debug('[egg]: init single process egg end');
|
|
69
|
-
// https config
|
|
70
|
-
if (this.configurationOptions.key && this.configurationOptions.cert) {
|
|
71
|
-
this.configurationOptions.key = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.key);
|
|
72
|
-
this.configurationOptions.cert = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.cert);
|
|
73
|
-
this.configurationOptions.ca = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.ca);
|
|
74
|
-
if (this.configurationOptions.http2) {
|
|
75
|
-
this.server = require('http2').createSecureServer(this.configurationOptions, this.app.callback());
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.server = require('https').createServer(this.configurationOptions, this.app.callback());
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (this.configurationOptions.http2) {
|
|
83
|
-
this.server = require('http2').createServer(this.app.callback());
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
this.server = require('http').createServer(this.app.callback());
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
67
|
}
|
|
90
68
|
async applicationInitialize(options) {
|
|
91
69
|
if (!this.isClusterMode) {
|
|
92
70
|
await this.initSingleProcessEgg();
|
|
93
71
|
}
|
|
94
72
|
// insert error handler
|
|
95
|
-
|
|
73
|
+
const midwayRootMiddleware = async (ctx, next) => {
|
|
96
74
|
// this.app.createAnonymousContext(ctx);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (result) {
|
|
102
|
-
ctx.body = result;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
this.generator = new EggControllerGenerator(this.app, this.applicationContext, this.appLogger);
|
|
75
|
+
await (await this.applyMiddleware())(ctx, next);
|
|
76
|
+
};
|
|
77
|
+
this.app.use(midwayRootMiddleware);
|
|
78
|
+
this.generator = new EggControllerGenerator(this.app);
|
|
106
79
|
this.overwriteApplication('app');
|
|
107
80
|
await new Promise(resolve => {
|
|
108
81
|
this.app.once('application-ready', () => {
|
|
@@ -110,7 +83,7 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
110
83
|
resolve();
|
|
111
84
|
});
|
|
112
85
|
this.app.loader.loadOrigin();
|
|
113
|
-
//
|
|
86
|
+
// 这里拦截 app.use 方法,让他可以加到 midway 的 middlewareManager 中
|
|
114
87
|
this.app.originUse = this.app.use;
|
|
115
88
|
this.app.use = this.app.useMiddleware;
|
|
116
89
|
this.app.ready();
|
|
@@ -136,7 +109,11 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
136
109
|
debug(`[egg]: overwrite properties to "${processType}"`);
|
|
137
110
|
this.defineApplicationProperties({
|
|
138
111
|
generateController: (controllerMapping) => {
|
|
139
|
-
|
|
112
|
+
const [controllerId, methodName] = controllerMapping.split('.');
|
|
113
|
+
return this.generator.generateController({
|
|
114
|
+
id: controllerId,
|
|
115
|
+
method: methodName,
|
|
116
|
+
});
|
|
140
117
|
},
|
|
141
118
|
generateMiddleware: async (middlewareId) => {
|
|
142
119
|
return this.generateMiddleware(middlewareId);
|
|
@@ -156,19 +133,46 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
156
133
|
logger_2.MidwayEggContextLogger);
|
|
157
134
|
}
|
|
158
135
|
async loadMidwayController() {
|
|
159
|
-
await this.generator.loadMidwayController(newRouter => {
|
|
160
|
-
|
|
136
|
+
await this.generator.loadMidwayController(this.configurationOptions.globalPrefix, newRouter => {
|
|
137
|
+
var _a;
|
|
138
|
+
const dispatchFn = newRouter.middleware();
|
|
139
|
+
dispatchFn._name = `midwayController(${((_a = newRouter === null || newRouter === void 0 ? void 0 : newRouter.opts) === null || _a === void 0 ? void 0 : _a.prefix) || '/'})`;
|
|
140
|
+
this.app.useMiddleware(dispatchFn);
|
|
161
141
|
});
|
|
162
142
|
}
|
|
163
143
|
getFrameworkType() {
|
|
164
144
|
return decorator_1.MidwayFrameworkType.WEB;
|
|
165
145
|
}
|
|
166
146
|
async run() {
|
|
147
|
+
var _a;
|
|
148
|
+
// move egg router to last
|
|
149
|
+
this.app.getMiddleware().findAndInsertLast('eggRouterMiddleware');
|
|
167
150
|
// load controller
|
|
168
151
|
await this.loadMidwayController();
|
|
169
152
|
// restore use method
|
|
170
153
|
this.app.use = this.app.originUse;
|
|
154
|
+
debug(`[egg]: current middleware = ${this.middlewareManager.getNames()}`);
|
|
171
155
|
if (!this.isClusterMode) {
|
|
156
|
+
// https config
|
|
157
|
+
if (this.configurationOptions.key && this.configurationOptions.cert) {
|
|
158
|
+
this.configurationOptions.key = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.key);
|
|
159
|
+
this.configurationOptions.cert = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.cert);
|
|
160
|
+
this.configurationOptions.ca = core_1.PathFileUtil.getFileContentSync(this.configurationOptions.ca);
|
|
161
|
+
if (this.configurationOptions.http2) {
|
|
162
|
+
this.server = require('http2').createSecureServer(this.configurationOptions, this.app.callback());
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.server = require('https').createServer(this.configurationOptions, this.app.callback());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (this.configurationOptions.http2) {
|
|
170
|
+
this.server = require('http2').createServer(this.app.callback());
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
this.server = require('http').createServer(this.app.callback());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
172
176
|
// emit egg-ready message in agent and application
|
|
173
177
|
this.app.messenger.broadcast('egg-ready', undefined);
|
|
174
178
|
// emit `server` event in app
|
|
@@ -176,17 +180,21 @@ let MidwayWebFramework = class MidwayWebFramework extends core_1.BaseFramework {
|
|
|
176
180
|
// register httpServer to applicationContext
|
|
177
181
|
this.getApplicationContext().registerObject(core_1.HTTP_SERVER_KEY, this.server);
|
|
178
182
|
const eggConfig = this.configService.getConfiguration('egg');
|
|
179
|
-
if (this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
args
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
if (!this.isClusterMode && eggConfig) {
|
|
184
|
+
const customPort = (_a = process.env.MIDWAY_HTTP_PORT) !== null && _a !== void 0 ? _a : eggConfig.port;
|
|
185
|
+
if (customPort) {
|
|
186
|
+
new Promise(resolve => {
|
|
187
|
+
const args = [customPort];
|
|
188
|
+
if (eggConfig.hostname) {
|
|
189
|
+
args.push(eggConfig.hostname);
|
|
190
|
+
}
|
|
191
|
+
args.push(() => {
|
|
192
|
+
resolve();
|
|
193
|
+
});
|
|
194
|
+
this.server.listen(...args);
|
|
195
|
+
process.env.MIDWAY_HTTP_PORT = String(customPort);
|
|
187
196
|
});
|
|
188
|
-
|
|
189
|
-
});
|
|
197
|
+
}
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
}
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Context as EggContext, Application as EggApplication,
|
|
3
|
-
import { IMidwayContainer, IMidwayContext, Context as IMidwayBaseContext, IMidwayApplication, IMidwayBaseApplication, IConfigurationOptions } from '@midwayjs/core';
|
|
4
|
-
import { DefaultState, Middleware
|
|
2
|
+
import { Context as EggContext, Application as EggApplication, EggAppConfig } from 'egg';
|
|
3
|
+
import { IMidwayContainer, IMidwayContext, Context as IMidwayBaseContext, IMidwayApplication, IMidwayBaseApplication, IConfigurationOptions, NextFunction as BaseNextFunction } from '@midwayjs/core';
|
|
4
|
+
import { DefaultState, Middleware } from 'koa';
|
|
5
5
|
import { ILogger, LoggerOptions } from '@midwayjs/logger';
|
|
6
6
|
export interface IMidwayWebBaseApplication {
|
|
7
7
|
applicationContext: IMidwayContainer;
|
|
8
|
-
getLogger(name?: string):
|
|
9
|
-
getCoreLogger():
|
|
10
|
-
generateController?(controllerMapping: string): any;
|
|
8
|
+
getLogger(name?: string): ILogger;
|
|
9
|
+
getCoreLogger(): ILogger;
|
|
11
10
|
generateMiddleware?(middlewareId: string): Promise<Middleware<DefaultState, EggContext>>;
|
|
12
|
-
createLogger(name: string, options: LoggerOptions):
|
|
11
|
+
createLogger(name: string, options: LoggerOptions): ILogger;
|
|
13
12
|
}
|
|
14
13
|
declare module 'egg' {
|
|
15
14
|
interface EggAppInfo {
|
|
16
15
|
appDir: string;
|
|
17
16
|
}
|
|
18
|
-
interface Application extends IMidwayBaseApplication
|
|
17
|
+
interface Application extends IMidwayBaseApplication<Context>, IMidwayWebBaseApplication {
|
|
19
18
|
createAnonymousContext(...args: any[]): EggContext;
|
|
20
19
|
getCoreLogger(): EggLogger & ILogger;
|
|
21
20
|
getLogger(name?: string): EggLogger & ILogger;
|
|
22
21
|
createLogger(name: string, options: LoggerOptions): EggLogger & ILogger;
|
|
23
22
|
}
|
|
24
23
|
interface Context<ResponseBodyT = any> extends IMidwayBaseContext {
|
|
25
|
-
getLogger(name?: string):
|
|
24
|
+
getLogger(name?: string): ILogger;
|
|
26
25
|
}
|
|
27
26
|
interface EggAppConfig {
|
|
28
27
|
midwayFeature: {
|
|
@@ -36,7 +35,8 @@ export interface Application extends IMidwayWebApplication {
|
|
|
36
35
|
export interface Context<ResponseBodyT = unknown> extends IMidwayWebContext<ResponseBodyT> {
|
|
37
36
|
}
|
|
38
37
|
export declare type IMidwayWebContext<ResponseBodyT = unknown> = IMidwayContext<EggContext<ResponseBodyT>>;
|
|
39
|
-
export declare type IMidwayWebNext =
|
|
38
|
+
export declare type IMidwayWebNext = BaseNextFunction;
|
|
39
|
+
export declare type NextFunction = BaseNextFunction;
|
|
40
40
|
export interface IMidwayWebConfigurationOptions extends IConfigurationOptions {
|
|
41
41
|
app?: IMidwayWebApplication;
|
|
42
42
|
plugins?: {
|
|
@@ -73,9 +73,26 @@ export interface IMidwayWebConfigurationOptions extends IConfigurationOptions {
|
|
|
73
73
|
* http2 support
|
|
74
74
|
*/
|
|
75
75
|
http2?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* http global prefix
|
|
78
|
+
*/
|
|
79
|
+
globalPrefix?: string;
|
|
76
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated since version 3.0.0
|
|
83
|
+
* Please use IMiddleware from @midwayjs/core
|
|
84
|
+
*/
|
|
77
85
|
export declare type MidwayWebMiddleware = Middleware<DefaultState, Context>;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated since version 3.0.0
|
|
88
|
+
* Please use IMiddleware from @midwayjs/core
|
|
89
|
+
*/
|
|
78
90
|
export interface IWebMiddleware {
|
|
79
91
|
resolve(): MidwayWebMiddleware;
|
|
80
92
|
}
|
|
93
|
+
declare module '@midwayjs/core/dist/interface' {
|
|
94
|
+
interface MidwayConfig extends EggAppConfig {
|
|
95
|
+
egg?: IMidwayWebConfigurationOptions;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
81
98
|
//# sourceMappingURL=interface.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/web",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
4
|
"description": "Midway Web Framework for Egg.js",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@midwayjs/decorator": "^3.0.0-beta.
|
|
31
|
-
"@midwayjs/
|
|
30
|
+
"@midwayjs/decorator": "^3.0.0-beta.10",
|
|
31
|
+
"@midwayjs/logger": "^3.0.0-beta.10",
|
|
32
|
+
"@midwayjs/mock": "^3.0.0-beta.10",
|
|
32
33
|
"dayjs": "^1.10.7",
|
|
33
34
|
"egg-logger": "^2.4.2",
|
|
34
35
|
"egg-mock": "^3.26.0",
|
|
@@ -43,8 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@eggjs/router": "^2.0.0",
|
|
46
|
-
"@midwayjs/core": "^3.0.0-beta.
|
|
47
|
-
"@midwayjs/logger": "^3.0.0-beta.1",
|
|
47
|
+
"@midwayjs/core": "^3.0.0-beta.10",
|
|
48
48
|
"egg": "^2.28.0",
|
|
49
49
|
"extend2": "^1.0.0",
|
|
50
50
|
"find-up": "^5.0.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=12"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "153870f2e2dd6b17673ec7591e49224a6bd51b36"
|
|
62
62
|
}
|