ee-core 1.5.2-beta.1 → 2.0.0-beta.1

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 (72) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +2 -2
  3. package/addon/window/index.js +91 -91
  4. package/bin/tools.js +18 -18
  5. package/config/config.default.js +287 -280
  6. package/core/index.js +12 -12
  7. package/core/lib/ee.js +218 -218
  8. package/core/lib/loader/context_loader.js +106 -106
  9. package/core/lib/loader/ee_loader.js +461 -457
  10. package/core/lib/loader/file_loader.js +325 -325
  11. package/core/lib/loader/mixin/addon.js +32 -32
  12. package/core/lib/loader/mixin/config.js +135 -135
  13. package/core/lib/loader/mixin/controller.js +125 -124
  14. package/core/lib/loader/mixin/service.js +28 -28
  15. package/core/lib/utils/base_context_class.js +34 -34
  16. package/core/lib/utils/function.js +30 -0
  17. package/core/lib/utils/index.js +127 -127
  18. package/core/lib/utils/sequencify.js +59 -59
  19. package/core/lib/utils/timing.js +77 -77
  20. package/index.js +49 -49
  21. package/lib/appLoader.js +48 -53
  22. package/lib/application.js +85 -84
  23. package/lib/baseApp.js +114 -131
  24. package/lib/eeApp.js +325 -359
  25. package/{lib/constant.js → module/const/index.js} +12 -9
  26. package/{lib/httpclient.js → module/httpclient/index.js} +170 -136
  27. package/module/jobs/child/forkProcess.js +99 -0
  28. package/module/jobs/child/index.js +33 -0
  29. package/module/jobs/index.js +55 -0
  30. package/module/jobs/renderer/index.js +140 -0
  31. package/module/jobs/renderer/loadView.js +40 -0
  32. package/module/loader/index.js +78 -0
  33. package/module/log/index.js +53 -0
  34. package/module/log/logger.js +61 -0
  35. package/module/message/index.js +13 -0
  36. package/module/message/ipcMain.js +160 -0
  37. package/module/message/ipcRender.js +0 -0
  38. package/{lib → module}/socket/httpServer.js +142 -142
  39. package/{lib → module}/socket/io.js +23 -23
  40. package/{lib → module}/socket/ipcServer.js +106 -108
  41. package/{lib → module}/socket/socketClient.js +51 -50
  42. package/{lib → module}/socket/socketServer.js +77 -76
  43. package/module/socket/start.js +22 -0
  44. package/{lib → module}/storage/index.js +35 -34
  45. package/module/storage/jsondb/adapters/Base.js +14 -0
  46. package/module/storage/jsondb/adapters/FileSync.js +32 -0
  47. package/{lib/storage/lowdb → module/storage/jsondb}/main.js +42 -46
  48. package/{lib/storage/lowdbStorage.js → module/storage/jsondbStorage.js} +98 -99
  49. package/{lib → module}/storage/sqliteStorage.js +123 -127
  50. package/module/utils/copyto.js +161 -0
  51. package/module/utils/helper.js +117 -0
  52. package/module/utils/index.js +120 -0
  53. package/module/utils/json.js +72 -0
  54. package/module/utils/ps.js +175 -0
  55. package/{utils → module/utils}/wrap.js +35 -37
  56. package/package.json +44 -48
  57. package/tools/encrypt.js +274 -274
  58. package/tools/replaceDist.js +61 -61
  59. package/utils/index.js +128 -246
  60. package/lib/logger.js +0 -47
  61. package/lib/socket/start.js +0 -22
  62. package/lib/storage/lowdb/adapters/Base.js +0 -15
  63. package/lib/storage/lowdb/adapters/FileAsync.js +0 -41
  64. package/lib/storage/lowdb/adapters/FileSync.js +0 -39
  65. package/lib/storage/lowdb/adapters/LocalStorage.js +0 -20
  66. package/lib/storage/lowdb/adapters/Memory.js +0 -8
  67. package/lib/storage/lowdb/adapters/_stringify.js +0 -4
  68. package/lib/storage/lowdb/common.js +0 -33
  69. package/lib/storage/lowdb/fp.js +0 -23
  70. package/lib/storage/lowdb/is-promise.js +0 -6
  71. package/lib/storage/lowdb/nano.js +0 -5
  72. package/utils/common.js +0 -91
@@ -1,32 +1,32 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
-
5
- /**
6
- * Load app/addon
7
- * @param {Object} opt - LoaderOptions
8
- * @function
9
- * @since 1.0.0
10
- */
11
- loadAddon(opt) {
12
- this.timing.start('Load Addon');
13
-
14
- // 加载ee-core的插件 和 用户插件
15
- const directorys = [
16
- path.join(this.options.framework, 'addon'),
17
- path.join(this.options.baseDir, 'addon'),
18
- ]
19
- opt = Object.assign({
20
- call: true,
21
- caseStyle: 'lower',
22
- directory: directorys
23
- }, opt);
24
-
25
- const addonPaths = opt.directory;
26
- this.loadToContext(addonPaths, 'addon', opt);
27
-
28
- this.timing.end('Load Addon');
29
- },
30
- };
31
-
32
-
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+
5
+ /**
6
+ * Load app/addon
7
+ * @param {Object} opt - LoaderOptions
8
+ * @function
9
+ * @since 1.0.0
10
+ */
11
+ loadAddon(opt) {
12
+ this.timing.start('Load Addon');
13
+
14
+ // 加载ee-core的插件 和 用户插件
15
+ const directorys = [
16
+ path.join(this.options.framework, 'addon'),
17
+ path.join(this.options.baseDir, 'addon'),
18
+ ]
19
+ opt = Object.assign({
20
+ call: true,
21
+ caseStyle: 'lower',
22
+ directory: directorys
23
+ }, opt);
24
+
25
+ const addonPaths = opt.directory;
26
+ this.loadToContext(addonPaths, 'addon', opt);
27
+
28
+ this.timing.end('Load Addon');
29
+ },
30
+ };
31
+
32
+
@@ -1,135 +1,135 @@
1
- 'use strict';
2
-
3
- const debug = require('debug')('ee-core:config');
4
- const path = require('path');
5
- const extend = require('extend2');
6
- const assert = require('assert');
7
- const { Console } = require('console');
8
-
9
- module.exports = {
10
-
11
- /**
12
- * Load config/config.js
13
- *
14
- * Will merge config.default.js 和 config.${env}.js
15
- *
16
- * @function EggLoader#loadConfig
17
- * @since 1.0.0
18
- */
19
- loadConfig() {
20
- this.timing.start('Load Config');
21
- this.configMeta = {};
22
-
23
- const target = {};
24
-
25
- // Load Application config first
26
- const appConfig = this._preloadAppConfig();
27
- //console.log('----------------------- appConfig:', appConfig);
28
-
29
- // plugin config.default
30
- // framework config.default
31
- // app config.default
32
- // plugin config.{env}
33
- // framework config.{env}
34
- // app config.{env}
35
- for (const filename of this.getTypeFiles('config')) {
36
- for (const unit of this.getLoadUnits()) {
37
- const isApp = unit.type === 'app';
38
- const config = this._loadConfig(unit.path, filename, isApp ? undefined : appConfig, unit.type);
39
-
40
- if (!config) {
41
- continue;
42
- }
43
-
44
- debug('Loaded config %s, %s, %j', unit.path, filename, config);
45
- extend(true, target, config);
46
- }
47
- }
48
-
49
- // load env from process.env.EE_APP_CONFIG
50
- const envConfig = this._loadConfigFromEnv();
51
- debug('Loaded config from private env, %j', envConfig);
52
- extend(true, target, envConfig);
53
-
54
- // You can manipulate the order of app.config.coreMiddleware and app.config.appMiddleware in app.js
55
- target.coreMiddleware = target.coreMiddlewares = target.coreMiddleware || [];
56
- target.appMiddleware = target.appMiddlewares = target.middleware || [];
57
-
58
- this.config = target;
59
- this.timing.end('Load Config');
60
- },
61
-
62
- _preloadAppConfig() {
63
- const names = [
64
- 'config.default',
65
- `config.${this.serverEnv}`,
66
- ];
67
- const target = {};
68
- for (const filename of names) {
69
- const config = this._loadConfig(this.options.baseDir, filename, undefined, 'app');
70
- extend(true, target, config);
71
- }
72
- return target;
73
- },
74
-
75
- _loadConfig(dirpath, filename, extraInject, type) {
76
- const isPlugin = type === 'plugin';
77
- const isApp = type === 'app';
78
- let filepath = this.resolveModule(path.join(dirpath, 'config', filename));
79
-
80
- // let config.js compatible
81
- if (filename === 'config.default' && !filepath) {
82
- filepath = this.resolveModule(path.join(dirpath, 'config/config'));
83
- }
84
-
85
- const config = this.loadFile(filepath, this.appInfo, extraInject);
86
-
87
- if (!config) return null;
88
-
89
- if (isPlugin || isApp) {
90
- assert(!config.coreMiddleware, 'Can not define coreMiddleware in app or plugin');
91
- }
92
- if (!isApp) {
93
- assert(!config.middleware, 'Can not define middleware in ' + filepath);
94
- }
95
-
96
- // store config meta, check where is the property of config come from.
97
- this._setConfigMeta(config, filepath);
98
-
99
- return config;
100
- },
101
-
102
- _loadConfigFromEnv() {
103
- const envConfigStr = process.env.EE_APP_CONFIG;
104
- if (!envConfigStr) return;
105
- try {
106
- const envConfig = JSON.parse(envConfigStr);
107
- this._setConfigMeta(envConfig, '<process.env.EE_APP_CONFIG>');
108
- return envConfig;
109
- } catch (err) {
110
- this.options.logger.warn('[ee-loader] process.env.EE_APP_CONFIG is not invalid JSON: %s', envConfigStr);
111
- }
112
- },
113
-
114
- _setConfigMeta(config, filepath) {
115
- config = extend(true, {}, config);
116
- setConfig(config, filepath);
117
- extend(true, this.configMeta, config);
118
- },
119
- };
120
-
121
- function setConfig(obj, filepath) {
122
- for (const key of Object.keys(obj)) {
123
- const val = obj[key];
124
- // ignore console
125
- if (key === 'console' && val && typeof val.Console === 'function' && val.Console === Console) {
126
- obj[key] = filepath;
127
- continue;
128
- }
129
- if (val && Object.getPrototypeOf(val) === Object.prototype && Object.keys(val).length > 0) {
130
- setConfig(val, filepath);
131
- continue;
132
- }
133
- obj[key] = filepath;
134
- }
135
- }
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('ee-core:config');
4
+ const path = require('path');
5
+ const extend = require('extend2');
6
+ const assert = require('assert');
7
+ const { Console } = require('console');
8
+
9
+ module.exports = {
10
+
11
+ /**
12
+ * Load config/config.js
13
+ *
14
+ * Will merge config.default.js 和 config.${env}.js
15
+ *
16
+ * @function EggLoader#loadConfig
17
+ * @since 1.0.0
18
+ */
19
+ loadConfig() {
20
+ this.timing.start('Load Config');
21
+ this.configMeta = {};
22
+
23
+ const target = {};
24
+
25
+ // Load Application config first
26
+ const appConfig = this._preloadAppConfig();
27
+ //console.log('----------------------- appConfig:', appConfig);
28
+
29
+ // plugin config.default
30
+ // framework config.default
31
+ // app config.default
32
+ // plugin config.{env}
33
+ // framework config.{env}
34
+ // app config.{env}
35
+ for (const filename of this.getTypeFiles('config')) {
36
+ for (const unit of this.getLoadUnits()) {
37
+ const isApp = unit.type === 'app';
38
+ const config = this._loadConfig(unit.path, filename, isApp ? undefined : appConfig, unit.type);
39
+
40
+ if (!config) {
41
+ continue;
42
+ }
43
+
44
+ debug('Loaded config %s, %s, %j', unit.path, filename, config);
45
+ extend(true, target, config);
46
+ }
47
+ }
48
+
49
+ // load env from process.env.EE_APP_CONFIG
50
+ const envConfig = this._loadConfigFromEnv();
51
+ debug('Loaded config from private env, %j', envConfig);
52
+ extend(true, target, envConfig);
53
+
54
+ // You can manipulate the order of app.config.coreMiddleware and app.config.appMiddleware in app.js
55
+ target.coreMiddleware = target.coreMiddlewares = target.coreMiddleware || [];
56
+ target.appMiddleware = target.appMiddlewares = target.middleware || [];
57
+
58
+ this.config = target;
59
+ this.timing.end('Load Config');
60
+ },
61
+
62
+ _preloadAppConfig() {
63
+ const names = [
64
+ 'config.default',
65
+ `config.${this.serverEnv}`,
66
+ ];
67
+ const target = {};
68
+ for (const filename of names) {
69
+ const config = this._loadConfig(this.options.baseDir, filename, undefined, 'app');
70
+ extend(true, target, config);
71
+ }
72
+ return target;
73
+ },
74
+
75
+ _loadConfig(dirpath, filename, extraInject, type) {
76
+ const isPlugin = type === 'plugin';
77
+ const isApp = type === 'app';
78
+ let filepath = this.resolveModule(path.join(dirpath, 'config', filename));
79
+
80
+ // let config.js compatible
81
+ if (filename === 'config.default' && !filepath) {
82
+ filepath = this.resolveModule(path.join(dirpath, 'config/config'));
83
+ }
84
+
85
+ const config = this.loadFile(filepath, this.appInfo, extraInject);
86
+
87
+ if (!config) return null;
88
+
89
+ if (isPlugin || isApp) {
90
+ assert(!config.coreMiddleware, 'Can not define coreMiddleware in app or plugin');
91
+ }
92
+ if (!isApp) {
93
+ assert(!config.middleware, 'Can not define middleware in ' + filepath);
94
+ }
95
+
96
+ // store config meta, check where is the property of config come from.
97
+ this._setConfigMeta(config, filepath);
98
+
99
+ return config;
100
+ },
101
+
102
+ _loadConfigFromEnv() {
103
+ const envConfigStr = process.env.EE_APP_CONFIG;
104
+ if (!envConfigStr) return;
105
+ try {
106
+ const envConfig = JSON.parse(envConfigStr);
107
+ this._setConfigMeta(envConfig, '<process.env.EE_APP_CONFIG>');
108
+ return envConfig;
109
+ } catch (err) {
110
+ this.options.logger.warn('[ee-loader] process.env.EE_APP_CONFIG is not invalid JSON: %s', envConfigStr);
111
+ }
112
+ },
113
+
114
+ _setConfigMeta(config, filepath) {
115
+ config = extend(true, {}, config);
116
+ setConfig(config, filepath);
117
+ extend(true, this.configMeta, config);
118
+ },
119
+ };
120
+
121
+ function setConfig(obj, filepath) {
122
+ for (const key of Object.keys(obj)) {
123
+ const val = obj[key];
124
+ // ignore console
125
+ if (key === 'console' && val && typeof val.Console === 'function' && val.Console === Console) {
126
+ obj[key] = filepath;
127
+ continue;
128
+ }
129
+ if (val && Object.getPrototypeOf(val) === Object.prototype && Object.keys(val).length > 0) {
130
+ setConfig(val, filepath);
131
+ continue;
132
+ }
133
+ obj[key] = filepath;
134
+ }
135
+ }
@@ -1,124 +1,125 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const is = require('is-type-of');
5
- const utility = require('utility');
6
- const utils = require('../../utils');
7
- const FULLPATH = require('../file_loader').FULLPATH;
8
-
9
- module.exports = {
10
-
11
- /**
12
- * Load app/controller
13
- * @param {Object} opt - LoaderOptions
14
- * @since 1.0.0
15
- */
16
- loadController(opt) {
17
- this.timing.start('Load Controller');
18
- opt = Object.assign({
19
- caseStyle: 'lower',
20
- directory: path.join(this.options.baseDir, 'controller'),
21
- initializer: (obj, opt) => {
22
- // return class if it exports a function
23
- // ```js
24
- // module.exports = app => {
25
- // return class HomeController extends app.Controller {};
26
- // }
27
- // ```
28
-
29
- if (is.function(obj) && !is.generatorFunction(obj) && !is.class(obj) && !is.asyncFunction(obj) && !utils.isBytecodeClass(obj)) {
30
- obj = obj(this.app);
31
- }
32
- if (is.class(obj) || utils.isBytecodeClass(obj)) {
33
- obj.prototype.pathName = opt.pathName;
34
- obj.prototype.fullPath = opt.path;
35
- return wrapClass(obj);
36
- }
37
- if (is.object(obj)) {
38
- return wrapObject(obj, opt.path);
39
- }
40
- // support generatorFunction for forward compatbility
41
- if (is.generatorFunction(obj) || is.asyncFunction(obj)) {
42
- return wrapObject({ 'module.exports': obj }, opt.path)['module.exports'];
43
- }
44
- return obj;
45
- },
46
- }, opt);
47
- const controllerBase = opt.directory;
48
-
49
- this.loadToApp(controllerBase, 'controller', opt);
50
- this.options.logger.info('[ee-core:loader] Controller loaded: %s', controllerBase);
51
- this.timing.end('Load Controller');
52
- },
53
-
54
- };
55
-
56
- // wrap the class, yield a object with middlewares
57
- function wrapClass(Controller) {
58
- let proto = Controller.prototype;
59
- const ret = {};
60
- // tracing the prototype chain
61
- while (proto !== Object.prototype) {
62
- const keys = Object.getOwnPropertyNames(proto);
63
- for (const key of keys) {
64
- // getOwnPropertyNames will return constructor
65
- // that should be ignored
66
- if (key === 'constructor') {
67
- continue;
68
- }
69
- // skip getter, setter & non-function properties
70
- const d = Object.getOwnPropertyDescriptor(proto, key);
71
- // prevent to override sub method
72
- if (is.function(d.value) && !ret.hasOwnProperty(key)) {
73
- ret[key] = methodToMiddleware(Controller, key);
74
- ret[key][FULLPATH] = Controller.prototype.fullPath + '#' + Controller.name + '.' + key + '()';
75
- }
76
- }
77
- proto = Object.getPrototypeOf(proto);
78
- }
79
-
80
- return ret;
81
-
82
- function methodToMiddleware(Controller, key) {
83
- return function classControllerMiddleware(...args) {
84
- const controller = new Controller(this);
85
- // if (!this.app.config.controller || !this.app.config.controller.supportParams) {
86
- // args = [ this ];
87
- // }
88
- //args = [ this ];
89
- return utils.callFn(controller[key], args, controller);
90
- };
91
- }
92
- }
93
-
94
- // wrap the method of the object, method can receive ctx as it's first argument
95
- function wrapObject(obj, path, prefix) {
96
- const keys = Object.keys(obj);
97
- const ret = {};
98
- for (const key of keys) {
99
- if (is.function(obj[key])) {
100
- const names = utility.getParamNames(obj[key]);
101
- if (names[0] === 'next') {
102
- throw new Error(`controller \`${prefix || ''}${key}\` should not use next as argument from file ${path}`);
103
- }
104
- ret[key] = functionToMiddleware(obj[key]);
105
- ret[key][FULLPATH] = `${path}#${prefix || ''}${key}()`;
106
- } else if (is.object(obj[key])) {
107
- ret[key] = wrapObject(obj[key], path, `${prefix || ''}${key}.`);
108
- }
109
- }
110
- return ret;
111
-
112
- function functionToMiddleware(func) {
113
- const objectControllerMiddleware = async function(...args) {
114
- // if (!this.app.config.controller || !this.app.config.controller.supportParams) {
115
- // args = [ this ];
116
- // }
117
- return await utils.callFn(func, args, this);
118
- };
119
- for (const key in func) {
120
- objectControllerMiddleware[key] = func[key];
121
- }
122
- return objectControllerMiddleware;
123
- }
124
- }
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const is = require('is-type-of');
5
+ const utilsFn = require('../../utils/function');
6
+ const utils = require('../../utils');
7
+ const FULLPATH = require('../file_loader').FULLPATH;
8
+
9
+ module.exports = {
10
+
11
+ /**
12
+ * Load app/controller
13
+ * @param {Object} opt - LoaderOptions
14
+ * @since 1.0.0
15
+ */
16
+ loadController(opt) {
17
+ this.timing.start('Load Controller');
18
+ opt = Object.assign({
19
+ caseStyle: 'lower',
20
+ directory: path.join(this.options.baseDir, 'controller'),
21
+ initializer: (obj, opt) => {
22
+ // return class if it exports a function
23
+ // ```js
24
+ // module.exports = app => {
25
+ // return class HomeController extends app.Controller {};
26
+ // }
27
+ // ```
28
+
29
+ if (is.function(obj) && !is.generatorFunction(obj) && !is.class(obj) && !is.asyncFunction(obj) && !utils.isBytecodeClass(obj)) {
30
+ obj = obj(this.app);
31
+ }
32
+ if (is.class(obj) || utils.isBytecodeClass(obj)) {
33
+ obj.prototype.pathName = opt.pathName;
34
+ obj.prototype.fullPath = opt.path;
35
+ return wrapClass(obj);
36
+ }
37
+ if (is.object(obj)) {
38
+ return wrapObject(obj, opt.path);
39
+ }
40
+ // support generatorFunction for forward compatbility
41
+ if (is.generatorFunction(obj) || is.asyncFunction(obj)) {
42
+ return wrapObject({ 'module.exports': obj }, opt.path)['module.exports'];
43
+ }
44
+ return obj;
45
+ },
46
+ }, opt);
47
+ const controllerBase = opt.directory;
48
+
49
+ this.loadToApp(controllerBase, 'controller', opt);
50
+ this.options.logger.info('[ee-core:loader] Controller loaded: %s', controllerBase);
51
+ this.timing.end('Load Controller');
52
+ },
53
+
54
+ };
55
+
56
+ // wrap the class, yield a object with middlewares
57
+ function wrapClass(Controller) {
58
+ let proto = Controller.prototype;
59
+ const ret = {};
60
+ // tracing the prototype chain
61
+ while (proto !== Object.prototype) {
62
+ const keys = Object.getOwnPropertyNames(proto);
63
+ for (const key of keys) {
64
+ // getOwnPropertyNames will return constructor
65
+ // that should be ignored
66
+ if (key === 'constructor') {
67
+ continue;
68
+ }
69
+ // skip getter, setter & non-function properties
70
+ const d = Object.getOwnPropertyDescriptor(proto, key);
71
+ // prevent to override sub method
72
+ if (is.function(d.value) && !ret.hasOwnProperty(key)) {
73
+ ret[key] = methodToMiddleware(Controller, key);
74
+ ret[key][FULLPATH] = Controller.prototype.fullPath + '#' + Controller.name + '.' + key + '()';
75
+ }
76
+ }
77
+ proto = Object.getPrototypeOf(proto);
78
+ }
79
+
80
+ return ret;
81
+
82
+ function methodToMiddleware(Controller, key) {
83
+ return function classControllerMiddleware(...args) {
84
+ const controller = new Controller(this);
85
+ // if (!this.app.config.controller || !this.app.config.controller.supportParams) {
86
+ // args = [ this ];
87
+ // }
88
+ //args = [ this ];
89
+ return utils.callFn(controller[key], args, controller);
90
+ };
91
+ }
92
+ }
93
+
94
+ // wrap the method of the object, method can receive ctx as it's first argument
95
+ function wrapObject(obj, path, prefix) {
96
+ const keys = Object.keys(obj);
97
+ const ret = {};
98
+ for (const key of keys) {
99
+ if (is.function(obj[key])) {
100
+ const names = utilsFn.getParamNames(obj[key]);
101
+ if (names[0] === 'next') {
102
+ throw new Error(`controller \`${prefix || ''}${key}\` should not use next as argument from file ${path}`);
103
+ }
104
+ ret[key] = functionToMiddleware(obj[key]);
105
+ ret[key][FULLPATH] = `${path}#${prefix || ''}${key}()`;
106
+ } else if (is.object(obj[key])) {
107
+ ret[key] = wrapObject(obj[key], path, `${prefix || ''}${key}.`);
108
+ }
109
+ }
110
+ return ret;
111
+
112
+ function functionToMiddleware(func) {
113
+ const objectControllerMiddleware = async function(...args) {
114
+ // if (!this.app.config.controller || !this.app.config.controller.supportParams) {
115
+ // args = [ this ];
116
+ // }
117
+ return await utils.callFn(func, args, this);
118
+ };
119
+ for (const key in func) {
120
+ objectControllerMiddleware[key] = func[key];
121
+ }
122
+ return objectControllerMiddleware;
123
+ }
124
+ }
125
+
@@ -1,28 +1,28 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
-
5
- module.exports = {
6
-
7
- /**
8
- * Load app/service
9
- * @function EeLoader#loadService
10
- * @param {Object} opt - LoaderOptions
11
- * @since 1.0.0
12
- */
13
- loadService(opt) {
14
- this.timing.start('Load Service');
15
- // 载入到 app.serviceClasses
16
- opt = Object.assign({
17
- call: true,
18
- caseStyle: 'lower',
19
- fieldClass: 'serviceClasses',
20
- directory: this.getLoadUnits().map(unit => path.join(unit.path, 'service')), // this.getLoadUnits().map(unit => path.join(unit.path, 'app/service'))
21
- }, opt);
22
-
23
- const servicePaths = opt.directory;
24
- this.loadToContext(servicePaths, 'service', opt);
25
- this.timing.end('Load Service');
26
- },
27
-
28
- };
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ module.exports = {
6
+
7
+ /**
8
+ * Load app/service
9
+ * @function EeLoader#loadService
10
+ * @param {Object} opt - LoaderOptions
11
+ * @since 1.0.0
12
+ */
13
+ loadService(opt) {
14
+ this.timing.start('Load Service');
15
+ // 载入到 app.serviceClasses
16
+ opt = Object.assign({
17
+ call: true,
18
+ caseStyle: 'lower',
19
+ fieldClass: 'serviceClasses',
20
+ directory: this.getLoadUnits().map(unit => path.join(unit.path, 'service')), // this.getLoadUnits().map(unit => path.join(unit.path, 'app/service'))
21
+ }, opt);
22
+
23
+ const servicePaths = opt.directory;
24
+ this.loadToContext(servicePaths, 'service', opt);
25
+ this.timing.end('Load Service');
26
+ },
27
+
28
+ };