-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp-config.js
147 lines (124 loc) · 4.29 KB
/
app-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
var path = require('path'),
_ = require('lodash');
var initGlobalConfig = function(){
var configurator = {
projDir: process.cwd(),
site: './bin/www',
env: process.env.NODE_ENV || 'development',
port: process.env.PORT || 3003,
dist: './public/dist/',
lib: './public/lib/',
jsonDir: './public/json/',
publicDir: './public/',
favDir: './public/fav/',
imagesDir: './public/images/',
devDir: './dev/',
assetsDir: './dev/server/config/assets/',
utils: './dev/server/config/assets/utils',
clientDir: './dev/client/',
clientAppDir: './dev/client/app/',
serverDir: './dev/server/',
serverAppDir: './dev/server/app/',
serverConfigDir: './dev/server/config/',
expressSrc: './dev/server/app/*',
expressViews: './dev/server/{,*/}views/'
};
var utils = require(configurator.utils);
var config = {
// modules: utils.getDirectories('modules'),
utilsDir: path.resolve(configurator.utils),
logger: path.resolve(configurator.serverConfigDir, 'lib/', 'logger'),
winston: path.resolve(configurator.serverConfigDir, 'lib/', 'winston'),
// apps: utils.getAppsDir(path.resolve(serverDir,'app')),
serverApps: {
name: 'app',
path: configurator.serverAppDir,
list: utils.getAppsDir(path.resolve(configurator.serverAppDir)),
src: utils.getGlobbedPaths(path.resolve(configurator.expressSrc)),
// config.serverApps.views
views: utils.getGlobbedPaths(path.resolve(configurator.expressViews)),
routes: [],
tests: []
},
models: function() {
return utils.getGlobbedPaths(path.resolve(this.serverAppDir, '*/rdbmsModels'));
},
view_engine: {
template: 'hbs',
ext: 'hbs'
},
uploads: {
profileUpload: {
dest: './dev/client/images/',
limits: {
fileSize: 100000
}
},
dossierUpload: {
dest: './public/dist/uploads/',
rename: function (fieldname, filename) {
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now()
},
limits: {
fileSize: 100000,
files: 10,
fields: 5
}
}
},
log: {
// logging with Morgan - https://github.com/expressjs/morgan
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'dev',
fileLogger: {
directoryPath: process.cwd(),
fileName: 'app.log',
maxsize: 10485760,
maxFiles: 2,
json: false
},
options: {
// stream: 'access.log'
}
}
};
// config.serverApps.tests
// config.serverApps.tests = utils.getGlobbedPaths(path.resolve(configurator.serverAppDir, 'tests/*'));
var apps = {};
// get server.app info
_.forEach(config.serverApps.list, function (app) {
apps[app] = {
name: app,
list: utils.getAppsDir(path.resolve(configurator.serverAppDir,app)),
path: path.resolve(configurator.serverAppDir,app),
src: utils.getGlobbedPaths(path.resolve(configurator.serverAppDir,app,'*'))
};
_.forEach(apps[app].list, function(item){
var srcFiles = utils.getGlobbedPaths(path.resolve(configurator.serverAppDir,app,item,'*'));
apps[app][item] = {
name: item,
list: utils.getAppsDir(path.resolve(configurator.serverAppDir,app,item)),
path: path.resolve(configurator.serverAppDir,app,item),
src: srcFiles
};
if (item === 'routes') {
config.serverApps.routes = _.union(config.serverApps.routes,srcFiles);
}
if (item === 'views') {
config.serverApps.views = _.union(config.serverApps.views,path.resolve(configurator.serverAppDir,app,item));
}
if (item === 'tests') {
config.serverApps.tests = _.union(config.serverApps.tests,srcFiles);
}
});
});
config.serverApps.content = apps;
configurator = _.extend(configurator, config);
utils.exportJSON(configurator, 'appConfig.json');
return configurator;
};
/**
* Set configuration object
*/
module.exports = initGlobalConfig();