import * as passwordGenerator from 'password-generator'
import { UserRole } from '../../shared'
-import { logger, mkdirpPromise, rimrafPromise } from '../helpers'
+import { mkdirpPromise, rimrafPromise } from '../helpers/core-utils'
+import { logger } from '../helpers/logger'
import { createApplicationActor, createUserAccountAndChannel } from '../lib/user'
import { UserModel } from '../models/account/user'
import { ApplicationModel } from '../models/application/application'
await createOAuthClientIfNotExist()
await createOAuthAdminIfNotExist()
} catch (err) {
- logger.error('Cannot install application.', err)
- throw err
+ logger.error('Cannot install application.', { err })
+ process.exit(-1)
}
}
// ---------------------------------------------------------------------------
function removeCacheDirectories () {
- const cacheDirectories = CACHE.DIRECTORIES
+ const cacheDirectories = Object.keys(CACHE)
+ .map(k => CACHE[k].DIRECTORY)
const tasks: Promise<any>[] = []
function createDirectoriesIfNotExist () {
const storage = CONFIG.STORAGE
- const cacheDirectories = CACHE.DIRECTORIES
+ const cacheDirectories = Object.keys(CACHE)
+ .map(k => CACHE[k].DIRECTORY)
- const tasks = []
+ const tasks: Promise<string>[] = []
for (const key of Object.keys(storage)) {
const dir = storage[key]
tasks.push(mkdirpPromise(dir))
// Our password is weak so do not validate it
validatePassword = false
} else {
- password = passwordGenerator(8, true)
+ password = passwordGenerator(16, true)
}
const userData = {
email,
password,
role,
+ nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
videoQuota: -1
}
const user = new UserModel(userData)
// Nothing to do, application already exist
if (exist === true) return undefined
- logger.info('Creating Application table.')
-
logger.info('Creating application account.')
const application = await ApplicationModel.create({