This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
config.js
executable file
·109 lines (102 loc) · 3.31 KB
/
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
var path = require('path');
global.application_root = __dirname;
var config = {
hostname : 'localhost',
port : 3000,
database : {
mongo : {
servers : [
'localhost:27017/express-chat'
],
options : {
server : {
auto_reconnect: true
},
db : {
safe : true
}
}
},
redis : {
host: 'localhost',
port: 6379
}
},
// express.js settings
settings : {
'debug' : false,
'env' : process.env.NODE_ENV || "development",
'trust proxy' : false,
//'view cache' : false, // enabled in production by default
//'views' : "app/views", // will be set to paths.views
'view engine' : 'html'
},
engines : {
'html': require('ejs-locals')
},
paths : {
root : application_root,
routes : path.join(application_root, 'urls.js'),
app : path.join(application_root, 'app'),
public_root : path.join(application_root, 'public'),
public_lib : path.join(application_root, 'public', 'lib'),
models : path.join(application_root, 'app', 'models'),
views : path.join(application_root, 'app', 'views'),
libs : path.join(application_root, 'app', 'libs'),
controllers : path.join(application_root, 'app', 'controllers'),
conf : path.join(application_root, 'app', 'conf'),
// crons : path.join(application_root, 'app', 'crons'),
favicon : path.join(application_root, 'public', 'favicon.ico'),
statics : {
'/static' : path.join(application_root, 'public'),
'/static/server_lib': path.join(application_root, 'app', 'libs')
}
},
session : {
secret : 'CHANGE_ME',
key : 'nirror.sid',
cookie : {
maxAge : 24 * 60 * 60 * 1000, // 1 day
path : '/',
httpOnly : true
},
reapInterval : 15 * 60 * 1000,
engine : 'mongo'
},
socketio : {
adapter: "redis"
},
limits : {
maxMessageLength : 3000,
maxUsernameLength : 50,
minMessageInterval: 1000, //ms
maxTotalUp : 200, // files
maxTotalDown : 2000, // files
maxSimulUp : 1,
maxSimulDown : 3,
maxUpMB : 1000,
maxDownMB : 10000,
uploadSpeedKBs : 500,
downloadSpeedKBs : 500,
reloadTimeMin : 6 * 60
}
};
module.exports = function(userconfig) {
return (userconfig) ? mergeRecursive(config, userconfig) : config;
}
function mergeRecursive(obj1, obj2) {
for(var p in obj2) {
try {
// Property in destination object set; update its value.
if(obj2[p].constructor==Object) {
obj1[p] = mergeRecursive(obj1[p], obj2[p]);
} else {
obj1[p] = obj2[p];
}
} catch(e) {
// Property in destination object not set; create it and set its value.
obj1[p] = obj2[p];
}
}
return obj1;
}