-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.js
102 lines (96 loc) · 2.56 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
/**
* Default Configuration.
* See https://github.com/mozilla/node-convict/blob/master/README.md for details.
*/
var convict = require('convict');
module.exports = function () {
// Check if we need to auto configure for a fast start.
var env = process.env.NODE_ENV || 'dev';
var configFile = process.env.FREIGHT_CONFIG || __dirname + '/' + env + '.json';
require('./autoconfig')(configFile);
var conf = convict({
env: {
doc: 'The applicaton environment.',
format: [ 'dev', 'test', 'stage', 'prod', 'production' ],
default: 'dev',
env: 'NODE_ENV'
},
log: {
level: {
default: 'info',
env: 'LOG_LEVEL'
}
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS'
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 8872,
env: 'PORT'
},
limit: {
doc: 'The bundle transmission size limit, in kb.',
format: 'nat',
default: 500
},
password: {
doc: 'The password that is used to create Freight bundles.',
format: String,
default: ''
},
storage: {
// TODO: You need to create this directory if it does not exist.
// This directory is also used as a static file directory for Freight bundles.
doc: 'Default bundle storage directory. Make sure it is somewhere in the Freight Server directory.',
format: String,
default: __dirname + '/../storage'
},
tempDir: {
// TODO: You need to create this directory if it does not exist.
doc: 'Default directory for temporary files.',
format: String,
default: __dirname + '/../temp'
},
// Redis config, see https://github.com/learnboost/kue#redis-connection-settings
redis: {
port: {
doc: 'Redis Port',
format: 'port',
default: 6379
},
host: {
doc: 'Redis IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1'
},
auth: {
doc: 'Redis Password.',
format: String,
default: ''
},
options: {
doc: 'Redis Options.',
format: Object,
default: {}
}
},
track: {
delay: {
doc: 'Repository update check delay in milliseconds',
format: 'nat',
default: 60 * 60000
}
}
});
// load environment dependent configuration
// TODO: development only for now, change it later.
conf.loadFile(configFile);
// perform configuration validation
conf.validate();
return conf;
};