@midwayjs/express 3.3.6 → 3.4.0-beta.2

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.
@@ -7,6 +7,7 @@ export declare class MidwayExpressFramework extends BaseFramework<IMidwayExpress
7
7
  app: IMidwayExpressApplication;
8
8
  private server;
9
9
  private expressMiddlewareService;
10
+ private webRouterService;
10
11
  configure(): IMidwayExpressConfigurationOptions;
11
12
  applicationInitialize(options: Partial<IMidwayBootstrapOptions>): Promise<void>;
12
13
  run(): Promise<void>;
package/dist/framework.js CHANGED
@@ -160,8 +160,14 @@ let MidwayExpressFramework = class MidwayExpressFramework extends core_1.BaseFra
160
160
  */
161
161
  generateController(routeInfo) {
162
162
  return (0, middlewareService_1.wrapAsyncHandler)(async (req, res, next) => {
163
- const controller = await req.requestContext.getAsync(routeInfo.id);
164
- const result = await controller[routeInfo.method].call(controller, req, res, next);
163
+ let result;
164
+ if (typeof routeInfo.method !== 'string') {
165
+ result = await routeInfo.method(req, res, next);
166
+ }
167
+ else {
168
+ const controller = await req.requestContext.getAsync(routeInfo.id);
169
+ result = await controller[routeInfo.method].call(controller, req, res, next);
170
+ }
165
171
  if (res.headersSent) {
166
172
  // return when response send
167
173
  return;
@@ -198,11 +204,13 @@ let MidwayExpressFramework = class MidwayExpressFramework extends core_1.BaseFra
198
204
  }
199
205
  async loadMidwayController() {
200
206
  var _a, _b;
201
- const collector = new core_1.WebRouterCollector('', {
202
- globalPrefix: this.configurationOptions.globalPrefix,
203
- });
204
- const routerTable = await collector.getRouterTable();
205
- const routerList = await collector.getRoutePriorityList();
207
+ this.webRouterService = await this.applicationContext.getAsync(core_1.MidwayWebRouterService, [
208
+ {
209
+ globalPrefix: this.configurationOptions.globalPrefix,
210
+ },
211
+ ]);
212
+ const routerTable = await this.webRouterService.getRouterTable();
213
+ const routerList = await this.webRouterService.getRoutePriorityList();
206
214
  const routerMiddlewares = [];
207
215
  for (const routerInfo of routerList) {
208
216
  // bind controller first
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/express",
3
- "version": "3.3.6",
3
+ "version": "3.4.0-beta.2",
4
4
  "description": "Midway Web Framework for Express",
5
5
  "main": "dist/index",
6
6
  "typings": "index.d.ts",
@@ -24,16 +24,16 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@midwayjs/decorator": "^3.3.4",
27
+ "@midwayjs/decorator": "^3.4.0-beta.2",
28
28
  "@midwayjs/logger": "^2.15.0",
29
- "@midwayjs/mock": "^3.3.5",
29
+ "@midwayjs/mock": "^3.4.0-beta.2",
30
30
  "@types/body-parser": "1.19.2",
31
31
  "@types/express": "4.17.13",
32
32
  "fs-extra": "10.0.1"
33
33
  },
34
34
  "dependencies": {
35
- "@midwayjs/core": "^3.3.5",
36
- "@midwayjs/express-session": "^3.3.5",
35
+ "@midwayjs/core": "^3.4.0-beta.2",
36
+ "@midwayjs/express-session": "^3.4.0-beta.2",
37
37
  "body-parser": "1.19.2",
38
38
  "cookie-parser": "^1.4.6",
39
39
  "express": "4.17.3"
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=12"
48
48
  },
49
- "gitHead": "cede47c56635e5f687528f6c8ed77d49ce9842a7"
49
+ "gitHead": "a61721d3946b30fd4cac183265edcd99b31ac72b"
50
50
  }