@midwayjs/core 3.0.0-beta.9 → 3.0.0

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.
Files changed (51) hide show
  1. package/dist/baseFramework.d.ts +2 -1
  2. package/dist/baseFramework.js +13 -10
  3. package/dist/common/applicationManager.d.ts +11 -0
  4. package/dist/common/applicationManager.js +70 -0
  5. package/dist/common/dataListener.d.ts +11 -0
  6. package/dist/common/dataListener.js +43 -0
  7. package/dist/common/fileDetector.js +1 -1
  8. package/dist/common/middlewareManager.js +2 -2
  9. package/dist/common/webGenerator.d.ts +3 -14
  10. package/dist/common/webGenerator.js +21 -33
  11. package/dist/common/webRouterCollector.js +3 -3
  12. package/dist/context/container.js +21 -11
  13. package/dist/context/managedResolverFactory.js +12 -5
  14. package/dist/context/requestContainer.js +2 -0
  15. package/dist/definitions/functionDefinition.d.ts +1 -0
  16. package/dist/definitions/functionDefinition.js +1 -0
  17. package/dist/definitions/objectCreator.js +9 -8
  18. package/dist/definitions/objectDefinition.d.ts +1 -0
  19. package/dist/definitions/objectDefinition.js +1 -0
  20. package/dist/error/base.d.ts +22 -3
  21. package/dist/error/base.js +34 -5
  22. package/dist/error/framework.d.ts +27 -2
  23. package/dist/error/framework.js +51 -14
  24. package/dist/error/http.d.ts +146 -41
  25. package/dist/error/http.js +164 -31
  26. package/dist/error/index.d.ts +1 -1
  27. package/dist/error/index.js +4 -1
  28. package/dist/functional/configuration.d.ts +2 -0
  29. package/dist/functional/configuration.js +10 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +5 -1
  32. package/dist/interface.d.ts +49 -27
  33. package/dist/service/aspectService.js +1 -1
  34. package/dist/service/configService.d.ts +3 -1
  35. package/dist/service/configService.js +23 -17
  36. package/dist/service/decoratorService.js +11 -5
  37. package/dist/service/environmentService.d.ts +1 -1
  38. package/dist/service/frameworkService.d.ts +3 -2
  39. package/dist/service/frameworkService.js +17 -12
  40. package/dist/service/lifeCycleService.js +5 -5
  41. package/dist/service/loggerService.d.ts +1 -1
  42. package/dist/service/middlewareService.d.ts +3 -4
  43. package/dist/service/middlewareService.js +7 -11
  44. package/dist/setup.js +7 -4
  45. package/dist/util/extend.d.ts +2 -0
  46. package/dist/util/extend.js +55 -0
  47. package/dist/util/webRouterParam.js +24 -4
  48. package/package.json +10 -12
  49. package/CHANGELOG.md +0 -2208
  50. package/dist/error/code.d.ts +0 -60
  51. package/dist/error/code.js +0 -65
@@ -30,7 +30,10 @@ let MidwayDecoratorService = class MidwayDecoratorService {
30
30
  if (methodDecoratorMetadataList) {
31
31
  // loop it, save this order for decorator run
32
32
  for (const meta of methodDecoratorMetadataList) {
33
- const { propertyName, key, metadata } = meta;
33
+ const { propertyName, key, metadata, impl } = meta;
34
+ if (!impl) {
35
+ continue;
36
+ }
34
37
  // add aspect implementation first
35
38
  this.aspectService.interceptPrototypeMethod(Clzz, propertyName, () => {
36
39
  const methodDecoratorHandler = this.methodDecoratorMap.get(key);
@@ -57,7 +60,10 @@ let MidwayDecoratorService = class MidwayDecoratorService {
57
60
  // joinPoint.args
58
61
  const newArgs = [...joinPoint.args];
59
62
  for (const meta of parameterDecoratorMetadata[methodName]) {
60
- const { propertyName, key, metadata, parameterIndex } = meta;
63
+ const { propertyName, key, metadata, parameterIndex, impl } = meta;
64
+ if (!impl) {
65
+ continue;
66
+ }
61
67
  const parameterDecoratorHandler = this.parameterDecoratorMap.get(key);
62
68
  if (!parameterDecoratorHandler) {
63
69
  throw new error_1.MidwayCommonError(`Parameter Decorator "${key}" handler not found, please register first.`);
@@ -95,15 +101,15 @@ let MidwayDecoratorService = class MidwayDecoratorService {
95
101
  });
96
102
  }
97
103
  registerPropertyHandler(decoratorKey, fn) {
98
- debug(`[core:decorator]: Register property decorator key="${decoratorKey}"`);
104
+ debug(`[core]: Register property decorator key="${decoratorKey}"`);
99
105
  this.propertyHandlerMap.set(decoratorKey, fn);
100
106
  }
101
107
  registerMethodHandler(decoratorKey, fn) {
102
- debug(`[core:decorator]: Register method decorator key="${decoratorKey}"`);
108
+ debug(`[core]: Register method decorator key="${decoratorKey}"`);
103
109
  this.methodDecoratorMap.set(decoratorKey, fn);
104
110
  }
105
111
  registerParameterHandler(decoratorKey, fn) {
106
- debug(`[core:decorator]: Register parameter decorator key="${decoratorKey}"`);
112
+ debug(`[core]: Register parameter decorator key="${decoratorKey}"`);
107
113
  this.parameterDecoratorMap.set(decoratorKey, fn);
108
114
  }
109
115
  /**
@@ -1,6 +1,6 @@
1
1
  import { IEnvironmentService } from '../interface';
2
2
  export declare class MidwayEnvironmentService implements IEnvironmentService {
3
- environment: string;
3
+ protected environment: string;
4
4
  getCurrentEnvironment(): string;
5
5
  setCurrentEnvironment(environment: string): void;
6
6
  isDevelopmentEnvironment(): boolean;
@@ -4,6 +4,7 @@ import { MidwayConfigService } from './configService';
4
4
  import { MidwayLoggerService } from './loggerService';
5
5
  import { MidwayDecoratorService } from './decoratorService';
6
6
  import { MidwayAspectService } from './aspectService';
7
+ import { MidwayApplicationManager } from '../common/applicationManager';
7
8
  export declare class MidwayFrameworkService {
8
9
  readonly applicationContext: IMidwayContainer;
9
10
  readonly globalOptions: any;
@@ -11,14 +12,14 @@ export declare class MidwayFrameworkService {
11
12
  loggerService: MidwayLoggerService;
12
13
  aspectService: MidwayAspectService;
13
14
  decoratorService: MidwayDecoratorService;
15
+ applicationManager: MidwayApplicationManager;
14
16
  constructor(applicationContext: IMidwayContainer, globalOptions: any);
15
17
  private mainFramework;
16
- private globalFrameworkMap;
17
18
  private globalFrameworkList;
18
19
  protected init(): Promise<void>;
19
20
  getMainApp(): any;
20
21
  getMainFramework(): IMidwayFramework<any, any, any, unknown, unknown>;
21
- getFramework(type: MidwayFrameworkType): IMidwayFramework<any, any, any, unknown, unknown>;
22
+ getFramework(namespaceOrFrameworkType: string | MidwayFrameworkType): IMidwayFramework<any, any, any, unknown, unknown>;
22
23
  runFramework(): Promise<void>;
23
24
  stopFramework(): Promise<void>;
24
25
  }
@@ -18,6 +18,7 @@ const baseFramework_1 = require("../baseFramework");
18
18
  const pipelineService_1 = require("./pipelineService");
19
19
  const decoratorService_1 = require("./decoratorService");
20
20
  const aspectService_1 = require("./aspectService");
21
+ const applicationManager_1 = require("../common/applicationManager");
21
22
  const util = require("util");
22
23
  const error_1 = require("../error");
23
24
  const debug = util.debuglog('midway:debug');
@@ -25,10 +26,10 @@ let MidwayFrameworkService = class MidwayFrameworkService {
25
26
  constructor(applicationContext, globalOptions) {
26
27
  this.applicationContext = applicationContext;
27
28
  this.globalOptions = globalOptions;
28
- this.globalFrameworkMap = new WeakMap();
29
29
  this.globalFrameworkList = [];
30
30
  }
31
31
  async init() {
32
+ var _a;
32
33
  // register base config hook
33
34
  this.decoratorService.registerPropertyHandler(decorator_1.CONFIG_KEY, (propertyName, meta) => {
34
35
  var _a;
@@ -51,7 +52,7 @@ let MidwayFrameworkService = class MidwayFrameworkService {
51
52
  let frameworks = (0, decorator_1.listModule)(decorator_1.FRAMEWORK_KEY);
52
53
  // filter proto
53
54
  frameworks = filterProtoFramework(frameworks);
54
- debug(`[core:framework]: Found Framework length = ${frameworks.length}`);
55
+ debug(`[core]: Found Framework length = ${frameworks.length}`);
55
56
  if (frameworks.length) {
56
57
  for (const frameworkClz of frameworks) {
57
58
  const frameworkInstance = await this.applicationContext.getAsync(frameworkClz, [this.applicationContext]);
@@ -62,24 +63,24 @@ let MidwayFrameworkService = class MidwayFrameworkService {
62
63
  applicationContext: this.applicationContext,
63
64
  ...this.globalOptions,
64
65
  });
65
- debug(`[core:framework]: Found Framework "${frameworkInstance.getFrameworkName()}" and initialize.`);
66
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and initialize.`);
66
67
  }
67
68
  else {
68
- debug(`[core:framework]: Found Framework "${frameworkInstance.getFrameworkName()}" and delay initialize.`);
69
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and delay initialize.`);
69
70
  }
70
71
  // app init
71
- this.globalFrameworkMap.set(frameworkInstance.getFrameworkType(), frameworkInstance);
72
+ const definition = this.applicationContext.registry.getDefinition((0, decorator_1.getProviderUUId)(frameworkClz));
73
+ this.applicationManager.addFramework((_a = definition === null || definition === void 0 ? void 0 : definition.namespace) !== null && _a !== void 0 ? _a : frameworkInstance.getFrameworkName(), frameworkInstance);
72
74
  this.globalFrameworkList.push(frameworkInstance);
73
75
  }
74
76
  // register @App decorator handler
75
77
  this.decoratorService.registerPropertyHandler(decorator_1.APPLICATION_KEY, (propertyName, mete) => {
76
78
  if (mete.type) {
77
- if (this.globalFrameworkMap.has(mete.type)) {
78
- return this.globalFrameworkMap.get(mete.type).getApplication();
79
- }
80
- else {
79
+ const framework = this.applicationManager.getApplication(mete.type);
80
+ if (!framework) {
81
81
  throw new error_1.MidwayCommonError(`Framework ${mete.type} not Found`);
82
82
  }
83
+ return framework;
83
84
  }
84
85
  else {
85
86
  return this.getMainApp();
@@ -107,8 +108,8 @@ let MidwayFrameworkService = class MidwayFrameworkService {
107
108
  getMainFramework() {
108
109
  return this.mainFramework;
109
110
  }
110
- getFramework(type) {
111
- return this.globalFrameworkMap.get(type);
111
+ getFramework(namespaceOrFrameworkType) {
112
+ return this.applicationManager.getFramework(namespaceOrFrameworkType);
112
113
  }
113
114
  async runFramework() {
114
115
  for (const frameworkInstance of this.globalFrameworkList) {
@@ -116,7 +117,7 @@ let MidwayFrameworkService = class MidwayFrameworkService {
116
117
  if (frameworkInstance.isEnable()) {
117
118
  // app init
118
119
  await frameworkInstance.run();
119
- debug(`[core:framework]: Found Framework "${frameworkInstance.getFrameworkName()}" and run.`);
120
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and run.`);
120
121
  }
121
122
  }
122
123
  }
@@ -142,6 +143,10 @@ __decorate([
142
143
  (0, decorator_1.Inject)(),
143
144
  __metadata("design:type", decoratorService_1.MidwayDecoratorService)
144
145
  ], MidwayFrameworkService.prototype, "decoratorService", void 0);
146
+ __decorate([
147
+ (0, decorator_1.Inject)(),
148
+ __metadata("design:type", applicationManager_1.MidwayApplicationManager)
149
+ ], MidwayFrameworkService.prototype, "applicationManager", void 0);
145
150
  __decorate([
146
151
  (0, decorator_1.Init)(),
147
152
  __metadata("design:type", Function),
@@ -23,7 +23,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
23
23
  async init() {
24
24
  // run lifecycle
25
25
  const cycles = (0, decorator_1.listModule)(decorator_1.CONFIGURATION_KEY);
26
- debug(`[core:lifecycle]: Found Configuration length = ${cycles.length}`);
26
+ debug(`[core]: Found Configuration length = ${cycles.length}`);
27
27
  const lifecycleInstanceList = [];
28
28
  for (const cycle of cycles) {
29
29
  if (cycle.target instanceof configuration_1.FunctionalConfiguration) {
@@ -32,7 +32,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
32
32
  }
33
33
  else {
34
34
  // 普通类写法
35
- debug(`[core:lifecycle]: run ${cycle.target.name} init`);
35
+ debug(`[core]: run ${cycle.target.name} init`);
36
36
  cycle.instance = await this.applicationContext.getAsync(cycle.target);
37
37
  }
38
38
  cycle.instance && lifecycleInstanceList.push(cycle);
@@ -80,7 +80,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
80
80
  if (Array.isArray(lifecycleInstanceOrList)) {
81
81
  for (const cycle of lifecycleInstanceOrList) {
82
82
  if (typeof cycle.instance[lifecycle] === 'function') {
83
- debug(`[core:lifecycle]: run ${cycle.instance.constructor.name} ${lifecycle}`);
83
+ debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
84
84
  const result = await cycle.instance[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
85
85
  if (resultHandler) {
86
86
  resultHandler(result);
@@ -90,7 +90,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
90
90
  }
91
91
  else {
92
92
  if (typeof lifecycleInstanceOrList[lifecycle] === 'function') {
93
- debug(`[core:lifecycle]: run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
93
+ debug(`[core]: run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
94
94
  const result = await lifecycleInstanceOrList[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
95
95
  if (resultHandler) {
96
96
  resultHandler(result);
@@ -101,7 +101,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
101
101
  async runObjectLifeCycle(lifecycleInstanceList, lifecycle) {
102
102
  for (const cycle of lifecycleInstanceList) {
103
103
  if (typeof cycle.instance[lifecycle] === 'function') {
104
- debug(`[core:lifecycle]: run ${cycle.instance.constructor.name} ${lifecycle}`);
104
+ debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
105
105
  return this.applicationContext[lifecycle](cycle.instance[lifecycle].bind(cycle.instance));
106
106
  }
107
107
  }
@@ -7,7 +7,7 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
7
7
  configService: MidwayConfigService;
8
8
  constructor(applicationContext: IMidwayContainer);
9
9
  protected init(): Promise<void>;
10
- transformEggConfig(): {
10
+ protected transformEggConfig(): {
11
11
  midwayLogger: {
12
12
  default: {};
13
13
  clients: {};
@@ -1,11 +1,10 @@
1
- import { CommonMiddleware, IMidwayContainer } from '../interface';
1
+ import { CommonMiddleware, IMidwayContainer, IMidwayApplication } from '../interface';
2
2
  export declare class MidwayMiddlewareService<T, R, N = unknown> {
3
3
  readonly applicationContext: IMidwayContainer;
4
4
  constructor(applicationContext: IMidwayContainer);
5
- compose(middleware: Array<CommonMiddleware<T, R, N> | string>, name?: string): Promise<{
6
- (context: any, next?: any): Promise<any>;
5
+ compose(middleware: Array<CommonMiddleware<T, R, N> | string>, app: IMidwayApplication, name?: string): Promise<{
6
+ (context: T, next?: any): Promise<any>;
7
7
  _name: string;
8
8
  }>;
9
- getMiddlewareName(mw: any): any;
10
9
  }
11
10
  //# sourceMappingURL=middlewareService.d.ts.map
@@ -17,20 +17,20 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
17
17
  constructor(applicationContext) {
18
18
  this.applicationContext = applicationContext;
19
19
  }
20
- async compose(middleware, name) {
20
+ async compose(middleware, app, name) {
21
21
  if (!Array.isArray(middleware)) {
22
22
  throw new error_1.MidwayParameterError('Middleware stack must be an array');
23
23
  }
24
24
  const newMiddlewareArr = [];
25
25
  for (let fn of middleware) {
26
- if ((0, decorator_1.isClass)(fn) || typeof fn === 'string') {
26
+ if (decorator_1.Types.isClass(fn) || typeof fn === 'string') {
27
27
  if (typeof fn === 'string' &&
28
28
  !this.applicationContext.hasDefinition(fn)) {
29
29
  throw new error_1.MidwayCommonError('Middleware definition not found in midway container');
30
30
  }
31
31
  const classMiddleware = await this.applicationContext.getAsync(fn);
32
32
  if (classMiddleware) {
33
- fn = classMiddleware.resolve();
33
+ fn = await classMiddleware.resolve(app);
34
34
  if (!classMiddleware.match && !classMiddleware.ignore) {
35
35
  if (!fn.name) {
36
36
  fn._name = classMiddleware.constructor.name;
@@ -88,11 +88,11 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
88
88
  index,
89
89
  })).then(result => {
90
90
  // need to set body
91
- if (context.body && !result) {
92
- result = context.body;
91
+ if (context['body'] && !result) {
92
+ result = context['body'];
93
93
  }
94
- else if (result && context.body !== result) {
95
- context.body = result;
94
+ else if (result && context['body'] !== result) {
95
+ context['body'] = result;
96
96
  }
97
97
  return result;
98
98
  });
@@ -113,10 +113,6 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
113
113
  }
114
114
  return composeFn;
115
115
  }
116
- getMiddlewareName(mw) {
117
- var _a;
118
- return (_a = mw.name) !== null && _a !== void 0 ? _a : mw._name;
119
- }
120
116
  };
121
117
  MidwayMiddlewareService = __decorate([
122
118
  (0, decorator_1.Provide)(),
package/dist/setup.js CHANGED
@@ -22,7 +22,7 @@ async function initializeGlobalApplicationContext(globalOptions) {
22
22
  // register baseDir and appDir
23
23
  applicationContext.registerObject('baseDir', baseDir);
24
24
  applicationContext.registerObject('appDir', appDir);
25
- if (globalOptions.moduleDirector !== false) {
25
+ if (globalOptions.moduleDetector !== false) {
26
26
  if (globalOptions.moduleDetector === undefined ||
27
27
  globalOptions.moduleDetector === 'file') {
28
28
  applicationContext.setFileDetector(new _1.DirectoryFileDetector({
@@ -44,6 +44,7 @@ async function initializeGlobalApplicationContext(globalOptions) {
44
44
  applicationContext.bindClass(_1.MidwayFrameworkService);
45
45
  applicationContext.bindClass(_1.MidwayMiddlewareService);
46
46
  applicationContext.bindClass(_1.MidwayLifeCycleService);
47
+ applicationContext.bindClass(_1.MidwayApplicationManager);
47
48
  // bind preload module
48
49
  if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
49
50
  for (const preloadModule of globalOptions.preloadModules) {
@@ -63,12 +64,14 @@ async function initializeGlobalApplicationContext(globalOptions) {
63
64
  await applicationContext.getAsync(_1.MidwayDecoratorService, [
64
65
  applicationContext,
65
66
  ]);
66
- if (!globalOptions.configurationModule) {
67
- globalOptions.configurationModule = [
67
+ if (!globalOptions.imports) {
68
+ globalOptions.imports = [
68
69
  (0, _1.safeRequire)((0, path_1.join)(globalOptions.baseDir, 'configuration')),
69
70
  ];
70
71
  }
71
- for (const configurationModule of [].concat(globalOptions.configurationModule)) {
72
+ for (const configurationModule of []
73
+ .concat(globalOptions.imports)
74
+ .concat(globalOptions.configurationModule)) {
72
75
  // load configuration and component
73
76
  applicationContext.load(configurationModule);
74
77
  }
@@ -0,0 +1,2 @@
1
+ export declare function extend(...args: any[]): any;
2
+ //# sourceMappingURL=extend.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extend = void 0;
4
+ /**
5
+ * fork from https://github.com/eggjs/extend2
6
+ */
7
+ const decorator_1 = require("@midwayjs/decorator");
8
+ function extend(...args) {
9
+ let options, name, src, copy, clone;
10
+ let target = args[0];
11
+ let i = 1;
12
+ const length = args.length;
13
+ let deep = false;
14
+ // Handle a deep copy situation
15
+ if (typeof target === 'boolean') {
16
+ deep = target;
17
+ target = args[1] || {};
18
+ // skip the boolean and the target
19
+ i = 2;
20
+ }
21
+ else if ((typeof target !== 'object' && typeof target !== 'function') ||
22
+ target == null) {
23
+ target = {};
24
+ }
25
+ for (; i < length; ++i) {
26
+ options = args[i];
27
+ // Only deal with non-null/undefined values
28
+ if (options == null)
29
+ continue;
30
+ // Extend the base object
31
+ for (name in options) {
32
+ if (name === '__proto__')
33
+ continue;
34
+ src = target[name];
35
+ copy = options[name];
36
+ // Prevent never-ending loop
37
+ if (target === copy)
38
+ continue;
39
+ // Recurse if we're merging plain objects
40
+ if (deep && copy && decorator_1.Types.isPlainObject(copy)) {
41
+ clone = src && decorator_1.Types.isPlainObject(src) ? src : {};
42
+ // Never move original objects, clone them
43
+ target[name] = extend(deep, clone, copy);
44
+ // Don't bring in undefined values
45
+ }
46
+ else if (typeof copy !== 'undefined') {
47
+ target[name] = copy;
48
+ }
49
+ }
50
+ }
51
+ // Return the modified object
52
+ return target;
53
+ }
54
+ exports.extend = extend;
55
+ //# sourceMappingURL=extend.js.map
@@ -22,9 +22,25 @@ const extractKoaLikeValue = (key, data, paramType) => {
22
22
  case decorator_1.RouteParamTypes.SESSION:
23
23
  return (0, index_1.transformRequestObjectByType)(data ? ctx.session[data] : ctx.session, paramType);
24
24
  case decorator_1.RouteParamTypes.FILESTREAM:
25
- return ctx.getFileStream && ctx.getFileStream(data);
25
+ if (ctx.getFileStream) {
26
+ return ctx.getFileStream(data);
27
+ }
28
+ else if (ctx.files) {
29
+ return ctx.files[0];
30
+ }
31
+ else {
32
+ return undefined;
33
+ }
26
34
  case decorator_1.RouteParamTypes.FILESSTREAM:
27
- return ctx.multipart && ctx.multipart(data);
35
+ if (ctx.multipart) {
36
+ return ctx.multipart(data);
37
+ }
38
+ else if (ctx.files) {
39
+ return ctx.files;
40
+ }
41
+ else {
42
+ return undefined;
43
+ }
28
44
  case decorator_1.RouteParamTypes.REQUEST_PATH:
29
45
  return ctx['path'];
30
46
  case decorator_1.RouteParamTypes.REQUEST_IP:
@@ -36,6 +52,8 @@ const extractKoaLikeValue = (key, data, paramType) => {
36
52
  else {
37
53
  return (0, index_1.transformRequestObjectByType)(data ? ctx.query[data] : ctx.query, paramType);
38
54
  }
55
+ case decorator_1.RouteParamTypes.FIELDS:
56
+ return data ? ctx.fields[data] : ctx.fields;
39
57
  default:
40
58
  return null;
41
59
  }
@@ -61,9 +79,9 @@ const extractExpressLikeValue = (key, data, paramType) => {
61
79
  case decorator_1.RouteParamTypes.SESSION:
62
80
  return (0, index_1.transformRequestObjectByType)(data ? req.session[data] : req.session, paramType);
63
81
  case decorator_1.RouteParamTypes.FILESTREAM:
64
- return req.getFileStream && req.getFileStream(data);
82
+ return req.files ? req.files[0] : undefined;
65
83
  case decorator_1.RouteParamTypes.FILESSTREAM:
66
- return req.multipart && req.multipart(data);
84
+ return req.files;
67
85
  case decorator_1.RouteParamTypes.REQUEST_PATH:
68
86
  return req['baseUrl'];
69
87
  case decorator_1.RouteParamTypes.REQUEST_IP:
@@ -75,6 +93,8 @@ const extractExpressLikeValue = (key, data, paramType) => {
75
93
  else {
76
94
  return (0, index_1.transformRequestObjectByType)(data ? req.query[data] : req.query, paramType);
77
95
  }
96
+ case decorator_1.RouteParamTypes.FIELDS:
97
+ return data ? req.fields[data] : req.fields;
78
98
  default:
79
99
  return null;
80
100
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
9
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
11
11
  "link": "npm link"
12
12
  },
13
13
  "keywords": [
@@ -21,22 +21,20 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@midwayjs/decorator": "^3.0.0-beta.9",
25
- "koa": "^2.13.4",
24
+ "@midwayjs/decorator": "^3.0.0",
25
+ "koa": "2.13.4",
26
26
  "midway-test-component": "*",
27
- "mm": "3",
28
- "sinon": "^7.2.2"
27
+ "mm": "3.2.0",
28
+ "sinon": "12.0.1"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@midwayjs/decorator": "*"
32
32
  },
33
33
  "dependencies": {
34
34
  "@midwayjs/glob": "^1.0.2",
35
- "@midwayjs/logger": "^3.0.0-beta.9",
35
+ "@midwayjs/logger": "2.14.0",
36
36
  "class-transformer": "^0.5.1",
37
- "extend2": "^1.0.0",
38
- "picomatch": "^2.2.2",
39
- "reflect-metadata": "^0.1.13"
37
+ "picomatch": "2.3.1"
40
38
  },
41
39
  "author": "Harry Chen <czy88840616@gmail.com>",
42
40
  "repository": {
@@ -46,5 +44,5 @@
46
44
  "engines": {
47
45
  "node": ">=12"
48
46
  },
49
- "gitHead": "d23e4a4fee58097b98461625c428a37d55535cec"
47
+ "gitHead": "55c26029bccf7bbb739fa1597e8f418dafa2caa0"
50
48
  }