3 const config
= require('config')
4 const mkdirp
= require('mkdirp')
5 const path
= require('path')
8 checkConfig: checkConfig
,
9 createDirectoriesIfNotExist: createDirectoriesIfNotExist
12 // Check the config files
13 function checkConfig () {
14 const required
= [ 'listen.port',
15 'webserver.https', 'webserver.host', 'webserver.port',
16 'database.host', 'database.port', 'database.suffix',
17 'storage.certs', 'storage.uploads', 'storage.logs',
21 for (const key
of required
) {
22 if (!config
.has(key
)) {
30 // Create directories for the storage if it doesn't exist
31 function createDirectoriesIfNotExist () {
32 const storages
= config
.get('storage')
34 for (const key
of Object
.keys(storages
)) {
35 const dir
= storages
[key
]
37 mkdirp
.sync(path
.join(__dirname
, '..', '..', dir
))
39 throw new Error('Cannot create ' + path
+ ':' + error
)
44 // ---------------------------------------------------------------------------
46 module
.exports
= checker