-import config = require('config')
+import * as config from 'config'
import { database as db } from './database'
import { CONFIG } from './constants'
+import { promisify0 } from '../helpers/core-utils'
// Some checks on configuration files
function checkConfig () {
'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews',
'admin.email', 'signup.enabled', 'transcoding.enabled', 'transcoding.threads'
]
- const miss = []
+ const miss: string[] = []
for (const key of required) {
if (!config.has(key)) {
}
// Check the available codecs
-function checkFFmpeg (callback) {
+function checkFFmpeg () {
const Ffmpeg = require('fluent-ffmpeg')
-
- Ffmpeg.getAvailableCodecs(function (err, codecs) {
- if (err) return callback(err)
- if (CONFIG.TRANSCODING.ENABLED === false) return callback(null)
-
- const canEncode = [ 'libx264' ]
- canEncode.forEach(function (codec) {
- if (codecs[codec] === undefined) {
- return callback(new Error('Unknown codec ' + codec + ' in FFmpeg.'))
- }
-
- if (codecs[codec].canEncode !== true) {
- return callback(new Error('Unavailable encode codec ' + codec + ' in FFmpeg'))
- }
+ const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
+
+ getAvailableCodecsPromise()
+ .then(codecs => {
+ if (CONFIG.TRANSCODING.ENABLED === false) return undefined
+
+ const canEncode = [ 'libx264' ]
+ canEncode.forEach(codec => {
+ if (codecs[codec] === undefined) {
+ throw new Error('Unknown codec ' + codec + ' in FFmpeg.')
+ }
+
+ if (codecs[codec].canEncode !== true) {
+ throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg')
+ }
+ })
})
-
- return callback(null)
- })
}
-function clientsExist (callback) {
- db.OAuthClient.countTotal(function (err, totalClients) {
- if (err) return callback(err)
-
- return callback(null, totalClients !== 0)
+function clientsExist () {
+ return db.OAuthClient.countTotal().then(totalClients => {
+ return totalClients !== 0
})
}
-function usersExist (callback) {
- db.User.countTotal(function (err, totalUsers) {
- if (err) return callback(err)
-
- return callback(null, totalUsers !== 0)
+function usersExist () {
+ return db.User.countTotal().then(totalUsers => {
+ return totalUsers !== 0
})
}