1 | var path = require('path');
|
2 |
|
3 |
|
4 |
|
5 | module.exports = function(core){
|
6 |
|
7 | setConfig();
|
8 | setPath();
|
9 |
|
10 | function getConfig(){
|
11 | var configPath = path.join(core.rootPath,core.appName,'/config/app.conf')
|
12 |
|
13 | try {
|
14 | return require(configPath);
|
15 | }catch(err){
|
16 | return require('./defaultConfig');
|
17 | }
|
18 | }
|
19 |
|
20 | function setPath(){
|
21 | core.set('appPath',path.join(core.rootPath ,core.appName));
|
22 | core.set('views',path.join(core.get('appPath'),core.get('viewsPath')||'views'));
|
23 | core.set('view engine',core.get('viewEngine'));
|
24 | core.set('controllerPath',path.join(core.get('appPath'),core.get('controllerPath')||'controllers'));
|
25 | core.set('modelPath',path.join(core.get('appPath'),core.get('modelPath')||'models'));
|
26 | core.set('publicFloder',path.join(core.rootPath,core.get('publicFloder')||'public'))
|
27 |
|
28 | }
|
29 |
|
30 | function setConfig(){
|
31 | alajs.echoInfo('(1) configuration success');
|
32 | var config = getConfig();
|
33 |
|
34 |
|
35 | for(var iteam in config['general']){
|
36 | core.set(iteam,config['general'][iteam]);
|
37 | }
|
38 |
|
39 |
|
40 | var env = config.general.env;
|
41 | for(var iteam in config[env]){
|
42 | core.set(iteam,config[env][iteam]);
|
43 | }
|
44 |
|
45 |
|
46 | }
|
47 |
|
48 | }
|
49 |
|