]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/initializers/checker.js
Create an "installer" module that create defaults clients/users...
[github/Chocobozzz/PeerTube.git] / server / initializers / checker.js
... / ...
CommitLineData
1'use strict'
2
3const config = require('config')
4
5const Users = require('../models/users')
6
7const checker = {
8 checkConfig: checkConfig,
9 clientsExist: clientsExist,
10 usersExist: usersExist
11}
12
13// Check the config files
14function checkConfig () {
15 const required = [ 'listen.port',
16 'webserver.https', 'webserver.host', 'webserver.port',
17 'database.host', 'database.port', 'database.suffix',
18 'storage.certs', 'storage.uploads', 'storage.logs',
19 'network.friends' ]
20 const miss = []
21
22 for (const key of required) {
23 if (!config.has(key)) {
24 miss.push(key)
25 }
26 }
27
28 return miss
29}
30
31function clientsExist (callback) {
32 Users.getClients(function (err, clients) {
33 if (err) return callback(err)
34
35 return callback(null, clients.length !== 0)
36 })
37}
38
39function usersExist (callback) {
40 Users.getUsers(function (err, users) {
41 if (err) return callback(err)
42
43 return callback(null, users.length !== 0)
44 })
45}
46
47// ---------------------------------------------------------------------------
48
49module.exports = checker