-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
140 lines (135 loc) · 3.11 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
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
var convict = require( 'convict' );
var colog = require( 'colog' );
var conf = convict( {
web: {
port: {
doc: 'The port to bind.',
format: 'port',
default: 3000,
env: 'PORT'
},
secret: {
doc: 'A secret string used to generate cookies.',
format: String,
default: Math.random().toString(36),
env: 'SECRET'
},
'i18n-cookie': {
doc: 'The name of the cookie storing the current language.',
format: String,
default: 'cinequeue-locale',
env: 'I18NCOOKIE'
},
language: {
doc: 'The default language. Should be an ISO 639 code.',
format: String, // regex should be here
default: 'en',
env: 'LANG'
}
},
fs: {
allow: {
doc: 'Whether access to the file system by the end user is allowed.',
format: Boolean,
default: false,
env: 'ALLOWFS'
},
path: {
doc: 'The file path to the files to be accessible to the end user.',
format: String,
default: '~',
env: 'FSPATH'
},
url: {
doc: 'The base URL for the file system.',
format: 'url',
default: 'http://127.0.0.1',
env: 'URL'
},
serve: {
doc: 'Whether to allow serving of files directly through the node.js app.',
format: Boolean,
default: true,
env: 'ALLOWSERV'
},
link: {
doc: 'Link to file URLs in the file system browser',
format: Boolean,
default: false,
},
},
playlist: {
allow: {
doc: 'Whether to allow users to view the playlist.',
format: Boolean,
default: true,
env: 'ALLOWPL'
},
histsize: {
doc: 'The number of past files to display in the playlist.',
format: Number,
default: 5,
env: 'PLAYLISTSIZE'
}
},
player: {
kill: {
doc: 'Whether to allow users to kill the program via the interface.',
format: Boolean,
default: false,
env: 'ALLOWKILL'
},
remote: {
doc: 'Whether to play files remotely via SSH.',
format: Boolean,
default: false,
env: 'REMOTEPLAY'
},
display: {
doc: 'The display to spawn the player on.',
format: String,
default: ':0',
env: 'DISPLAY'
},
remotehost: {
doc: 'If remote playing is on, the user/host string of the remote host.',
format: String,
default: 'media@localhost',
env: 'REMOTEHOST'
},
quiet: {
doc: 'If enabled, output from mplayer stdout and stderr is not printed.',
format: Boolean,
default: false,
env: 'QUIETMPLAYER'
}
},
config: {
json: {
doc: 'The path to the (optional) configuration JSON file.',
format: String,
default: 'config.json',
env: 'CONFIGFILE'
}
}
} );
try {
conf.loadFile( conf.get( 'config.json' ) );
colog.success( 'Loaded configuration from ' + conf.get( 'config.json' ) );
} catch ( e ) {
colog.warning( 'Unable to load configuration file.' );
colog.info( 'Using default configuration settings.' );
colog.info( 'Create ' + conf.get( 'config.json' ) + ' to change from the defaults.' );
}
try {
conf.validate();
colog.success( 'Configuration validated.' );
} catch ( e ) {
colog.headerError( 'Bad configuration loaded' );
colog.error( e );
process.exit( 1 );
}
if ( conf.get( 'web.secret' ) === conf.default( 'web.secret' ) ) {
colog.warning( 'Using default secret!' );
}
module.exports = conf;