]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/checker.js
Server: add database field validations
[github/Chocobozzz/PeerTube.git] / server / initializers / checker.js
index aea013fa9ab169a072f8f048c7cc7e151901ae86..2753604dc43bb6eb492a177b666cd20a8a2b982c 100644 (file)
@@ -1,10 +1,8 @@
 'use strict'
 
 const config = require('config')
-const mongoose = require('mongoose')
 
-const Client = mongoose.model('OAuthClient')
-const User = mongoose.model('User')
+const db = require('./database')
 
 const checker = {
   checkConfig,
@@ -29,7 +27,7 @@ function checkConfig () {
 function checkMissedConfig () {
   const required = [ 'listen.port',
     'webserver.https', 'webserver.hostname', 'webserver.port',
-    'database.hostname', 'database.port', 'database.suffix',
+    'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password',
     'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews'
   ]
   const miss = []
@@ -44,7 +42,7 @@ function checkMissedConfig () {
 }
 
 function clientsExist (callback) {
-  Client.list(function (err, clients) {
+  db.OAuthClient.list(function (err, clients) {
     if (err) return callback(err)
 
     return callback(null, clients.length !== 0)
@@ -52,7 +50,7 @@ function clientsExist (callback) {
 }
 
 function usersExist (callback) {
-  User.countTotal(function (err, totalUsers) {
+  db.User.countTotal(function (err, totalUsers) {
     if (err) return callback(err)
 
     return callback(null, totalUsers !== 0)