chanjs 1.0.23 → 1.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/core/chan.js +15 -11
  2. 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
- console.log()
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
- for(let i=0,item;i<dirs.length;i++){
171
- item = dirs[i];
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
- // this.app.use(this.router);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chanjs",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Chan.js基于express 纯js研发的轻量级mvc框架。",
5
5
  "main": "core/chan.js",
6
6
  "module": "core/chan.js",