chanjs 1.0.23 → 1.0.24
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/core/chan.js +15 -11
- package/package.json +1 -1
package/core/chan.js
CHANGED
@@ -58,8 +58,6 @@ class Chan {
|
|
58
58
|
const configPath = path.join(Chan.config.APP_PATH, "config/index.js");
|
59
59
|
if (fs.existsSync(configPath)) {
|
60
60
|
const config = require(configPath);
|
61
|
-
// let allConfig = {...Chan.config,...config};
|
62
|
-
// this.app.config = Chan.config = allConfig;
|
63
61
|
Chan.config = {...Chan.config,...config};
|
64
62
|
}
|
65
63
|
}
|
@@ -152,7 +150,7 @@ class Chan {
|
|
152
150
|
* @description app核心模块:日志、favicon 图标、cookie、json、url、模板引擎、静态资源
|
153
151
|
*/
|
154
152
|
loadCore(){
|
155
|
-
|
153
|
+
|
156
154
|
core(this.app, Chan.config);
|
157
155
|
}
|
158
156
|
|
@@ -167,16 +165,23 @@ class Chan {
|
|
167
165
|
.filter((dirent) => dirent.isDirectory())
|
168
166
|
.map((dirent) => dirent.name);
|
169
167
|
Chan[modules]={};
|
170
|
-
|
171
|
-
|
168
|
+
|
169
|
+
// 先加载所有服务
|
170
|
+
dirs.forEach(item => {
|
172
171
|
Chan[modules][item] = {
|
173
|
-
controller: {},
|
174
172
|
service: {},
|
173
|
+
controller: {},
|
175
174
|
};
|
175
|
+
this.loadServices(modules, item);
|
176
|
+
});
|
177
|
+
|
178
|
+
// 加载控制器和路由
|
179
|
+
dirs.forEach(item => {
|
176
180
|
this.loadModule(modules,item);
|
177
|
-
}
|
178
|
-
|
179
|
-
|
181
|
+
});
|
182
|
+
|
183
|
+
//执行路由
|
184
|
+
// this.app.use(this.router);
|
180
185
|
}
|
181
186
|
}
|
182
187
|
|
@@ -186,7 +191,6 @@ class Chan {
|
|
186
191
|
* @param {String} moduleName 模块名称
|
187
192
|
*/
|
188
193
|
loadModule(modules,moduleName) {
|
189
|
-
this.loadServices(modules,moduleName);
|
190
194
|
this.loadControllers(modules,moduleName);
|
191
195
|
this.loadRoutes(modules,moduleName);
|
192
196
|
}
|
@@ -269,5 +273,5 @@ class Chan {
|
|
269
273
|
});
|
270
274
|
}
|
271
275
|
}
|
272
|
-
|
276
|
+
global.Chan = Chan;
|
273
277
|
module.exports = Chan;
|