3 const config = require('config')
4 const mongoose = require('mongoose')
6 const Client = mongoose.model('OAuthClient')
7 const User = mongoose.model('User')
10 checkConfig: checkConfig,
11 clientsExist: clientsExist,
12 usersExist: usersExist
15 // Check the config files
16 function checkConfig () {
17 const required = [ 'listen.port',
18 'webserver.https', 'webserver.host', 'webserver.port',
19 'database.host', 'database.port', 'database.suffix',
20 'storage.certs', 'storage.uploads', 'storage.logs', 'storage.thumbnails',
24 for (const key of required) {
25 if (!config.has(key)) {
33 function clientsExist (callback) {
34 Client.list(function (err, clients) {
35 if (err) return callback(err)
37 return callback(null, clients.length !== 0)
41 function usersExist (callback) {
42 User.countTotal(function (err, totalUsers) {
43 if (err) return callback(err)
45 return callback(null, totalUsers !== 0)
49 // ---------------------------------------------------------------------------
51 module.exports = checker