]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/checker.js
Add check for the thumbnail in base64 (requests inter pods)
[github/Chocobozzz/PeerTube.git] / server / initializers / checker.js
1 'use strict'
2
3 const config = require('config')
4
5 const Users = require('../models/users')
6
7 const checker = {
8 checkConfig: checkConfig,
9 clientsExist: clientsExist,
10 usersExist: usersExist
11 }
12
13 // Check the config files
14 function 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', 'electron.debug' ]
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
31 function 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
39 function 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
49 module.exports = checker