refactor: remove config namespaces

This commit is contained in:
NGPixel
2018-05-28 14:46:55 -04:00
parent b1499d1d64
commit 416755f17a
27 changed files with 556 additions and 283 deletions

View File

@@ -23,12 +23,6 @@ defaults:
port: 6379
db: 0
password: null
configMode: auto
workers: 0
ha:
node: primary
uid: master
readonly: false
# DB defaults
auth:
public: false
@@ -36,8 +30,6 @@ defaults:
local:
isEnabled: true
allowSelfRegister: false
git:
enabled: false
logging:
telemetry: false
loggers:
@@ -48,6 +40,7 @@ defaults:
rtl: false
title: Wiki.js
# System defaults
setup: false
cors:
credentials: true
maxAge: 600

View File

@@ -1,10 +1,9 @@
/* global WIKI */
const _ = require('lodash')
const passport = require('passport')
const fs = require('fs-extra')
const _ = require('lodash')
const path = require('path')
const autoload = require('auto-load')
/* global WIKI */
module.exports = {
strategies: {},
@@ -30,34 +29,39 @@ module.exports = {
})
})
// Load authentication strategies
const modules = _.values(autoload(path.join(WIKI.SERVERPATH, 'modules/authentication')))
_.forEach(modules, (strategy) => {
const strategyConfig = _.get(WIKI.config.auth.strategies, strategy.key, { isEnabled: false })
strategyConfig.callbackURL = `${WIKI.config.site.host}${WIKI.config.site.path}login/${strategy.key}/callback`
strategy.config = strategyConfig
if (strategyConfig.isEnabled) {
try {
strategy.init(passport, strategyConfig)
} catch (err) {
WIKI.logger.error(`Authentication Provider ${strategy.title}: [ FAILED ]`)
WIKI.logger.error(err)
}
}
fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${strategy.key}.svg`), 'utf8').then(iconData => {
strategy.icon = iconData
}).catch(err => {
if (err.code === 'ENOENT') {
strategy.icon = '[missing icon]'
} else {
WIKI.logger.warn(err)
}
})
this.strategies[strategy.key] = strategy
WIKI.logger.info(`Authentication Provider ${strategy.title}: [ OK ]`)
})
return this
},
async activateStrategies() {
try {
// Unload any active strategies
WIKI.auth.strategies = []
const currentStrategies = _.keys(passport._strategies)
_.pull(currentStrategies, 'session')
_.forEach(currentStrategies, stg => { passport.unuse(stg) })
// Load enable strategies
const enabledStrategies = await WIKI.db.authentication.getEnabledStrategies()
for (let idx in enabledStrategies) {
const stg = enabledStrategies[idx]
const strategy = require(`../modules/authentication/${stg.key}`)
stg.config.callbackURL = `${WIKI.config.site.host}/login/${stg.key}/callback`
strategy.init(passport, stg.config)
fs.readFile(path.join(WIKI.ROOTPATH, `assets/svg/auth-icon-${strategy.key}.svg`), 'utf8').then(iconData => {
strategy.icon = iconData
}).catch(err => {
if (err.code === 'ENOENT') {
strategy.icon = '[missing icon]'
} else {
WIKI.logger.warn(err)
}
})
WIKI.auth.strategies[stg.key] = strategy
WIKI.logger.info(`Authentication Strategy ${stg.title}: [ OK ]`)
}
} catch (err) {
WIKI.logger.error(`Authentication Strategy: [ FAILED ]`)
WIKI.logger.error(err)
}
}
}

View File

@@ -50,45 +50,32 @@ module.exports = {
/**
* Load config from DB
*
* @param {Array} subsets Array of subsets to load
* @returns Promise
*/
async loadFromDb(subsets) {
if (!_.isArray(subsets) || subsets.length === 0) {
subsets = WIKI.data.configNamespaces
}
let results = await WIKI.db.settings.query().select(['key', 'value']).whereIn('key', subsets)
if (_.isArray(results) && results.length === subsets.length) {
results.forEach(result => {
WIKI.config[result.key] = result.value
})
return true
async loadFromDb() {
let conf = await WIKI.db.settings.getConfig()
if (conf) {
WIKI.config = _.defaultsDeep(conf, WIKI.config)
} else {
WIKI.logger.warn('DB Configuration is empty or incomplete.')
return false
WIKI.logger.warn('DB Configuration is empty or incomplete. Switching to Setup mode...')
WIKI.config.setup = true
}
},
/**
* Save config to DB
*
* @param {Array} subsets Array of subsets to save
* @param {Array} keys Array of keys to save
* @returns Promise
*/
async saveToDb(subsets) {
if (!_.isArray(subsets) || subsets.length === 0) {
subsets = WIKI.data.configNamespaces
}
async saveToDb(keys) {
let trx = await WIKI.db.Objection.transaction.start(WIKI.db.knex)
try {
for (let set of subsets) {
console.info(set)
await WIKI.db.settings.query(trx).patch({
value: _.get(WIKI.config, set, {})
}).where('key', set)
for (let key of keys) {
const value = _.get(WIKI.config, key, null)
let affectedRows = await WIKI.db.settings.query(trx).patch({ value }).where('key', key)
if (affectedRows === 0 && value) {
await WIKI.db.settings.query(trx).insert({ key, value })
}
}
await trx.commit()
} catch (err) {

View File

@@ -53,6 +53,20 @@ module.exports = {
client: dbClient,
useNullAsDefault: true,
connection: dbConfig,
pool: {
async afterCreate(conn, done) {
// -> Set Connection App Name
switch (WIKI.config.db.type) {
case 'postgres':
await conn.query(`set application_name = 'Wiki.js'`)
done()
break
default:
done()
break
}
}
},
debug: WIKI.IS_DEBUG
})
@@ -71,21 +85,13 @@ module.exports = {
directory: path.join(WIKI.SERVERPATH, 'db/migrations'),
tableName: 'migrations'
})
},
// -> Set Connection App Name
async setAppName() {
switch (WIKI.config.db.type) {
case 'postgres':
return self.knex.raw(`set application_name = 'Wiki.js'`)
}
}
}
let initTasksQueue = (WIKI.IS_MASTER) ? [
initTasks.syncSchemas,
initTasks.setAppName
initTasks.syncSchemas
] : [
initTasks.setAppName
() => { return Promise.resolve() }
]
// Perform init tasks

View File

@@ -1,89 +1,53 @@
const _ = require('lodash')
const cluster = require('cluster')
const Promise = require('bluebird')
/* global WIKI */
module.exports = {
numWorkers: 1,
workers: [],
init() {
if (cluster.isMaster) {
WIKI.logger.info('=======================================')
WIKI.logger.info('= Wiki.js =============================')
WIKI.logger.info('=======================================')
async init() {
WIKI.logger.info('=======================================')
WIKI.logger.info('= Wiki.js =============================')
WIKI.logger.info('=======================================')
WIKI.redis = require('./redis').init()
WIKI.queue = require('./queue').init()
WIKI.db = require('./db').init()
WIKI.redis = require('./redis').init()
WIKI.queue = require('./queue').init()
this.setWorkerLimit()
this.bootMaster()
} else {
this.bootWorker()
}
await this.preBootMaster()
this.bootMaster()
},
/**
* Pre-Master Boot Sequence
*/
preBootMaster() {
return Promise.mapSeries([
() => { return WIKI.db.onReady },
() => { return WIKI.configSvc.loadFromDb() },
() => { return WIKI.queue.clean() }
], fn => { return fn() })
async preBootMaster() {
try {
await WIKI.db.onReady
await WIKI.configSvc.loadFromDb()
await WIKI.queue.clean()
} catch (err) {
WIKI.logger.error(err)
process.exit(1)
}
},
/**
* Boot Master Process
*/
bootMaster() {
this.preBootMaster().then(sequenceResults => {
if (_.every(sequenceResults, rs => rs === true) && WIKI.config.configMode !== 'setup') {
this.postBootMaster()
} else {
WIKI.logger.info('Starting configuration manager...')
async bootMaster() {
try {
if (WIKI.config.setup) {
WIKI.logger.info('Starting setup wizard...')
require('../setup')()
} else {
await require('../master')()
this.postBootMaster()
}
return true
}).catch(err => {
} catch (err) {
WIKI.logger.error(err)
process.exit(1)
})
}
},
/**
* Post-Master Boot Sequence
*/
async postBootMaster() {
await require('../master')()
WIKI.queue.start()
cluster.on('exit', (worker, code, signal) => {
if (!global.DEV) {
WIKI.logger.info(`Background Worker #${worker.id} was terminated.`)
}
})
},
/**
* Boot Worker Process
*/
bootWorker() {
WIKI.logger.info(`Background Worker #${cluster.worker.id} is initializing...`)
require('../worker')
},
/**
* Spawn new Worker process
*/
spawnWorker() {
this.workers.push(cluster.fork())
},
/**
* Set Worker count based on config + system capabilities
*/
setWorkerLimit() {
const numCPUs = require('os').cpus().length
this.numWorkers = (WIKI.config.workers > 0) ? WIKI.config.workers : numCPUs
if (this.numWorkers > numCPUs) {
this.numWorkers = numCPUs
}
await WIKI.auth.activateStrategies()
await WIKI.queue.start()
}
}

View File

@@ -17,7 +17,7 @@ module.exports = {
ns: this.namespaces,
defaultNS: 'common',
saveMissing: false,
lng: WIKI.config.site.lang,
lng: WIKI.config.lang,
fallbackLng: 'en'
})
@@ -31,7 +31,7 @@ module.exports = {
}
// Load current language
this.loadLocale(WIKI.config.site.lang, { silent: true })
this.loadLocale(WIKI.config.lang, { silent: true })
return this
},
@@ -55,6 +55,7 @@ module.exports = {
const res = await WIKI.db.locales.query().findOne('code', locale)
if (res) {
if (_.isPlainObject(res.strings)) {
console.info(res.strings)
_.forOwn(res.strings, (data, ns) => {
this.namespaces.push(ns)
this.engine.addResourceBundle(locale, ns, data, true, true)

View File

@@ -23,6 +23,15 @@ exports.up = knex => {
table.string('slug').notNullable()
table.integer('parentId').unsigned().references('id').inTable('assetFolders')
})
// AUTHENTICATION ----------------------
.createTable('authentication', table => {
table.increments('id').primary()
table.string('key').notNullable().unique()
table.string('title').notNullable()
table.boolean('isEnabled').notNullable().defaultTo(false)
table.boolean('useForm').notNullable().defaultTo(false)
table.jsonb('config').notNullable()
})
// COMMENTS ----------------------------
.createTable('comments', table => {
table.increments('id').primary()
@@ -30,6 +39,14 @@ exports.up = knex => {
table.string('createdAt').notNullable()
table.string('updatedAt').notNullable()
})
// EDITORS -----------------------------
.createTable('editors', table => {
table.increments('id').primary()
table.string('key').notNullable().unique()
table.string('title').notNullable()
table.boolean('isEnabled').notNullable().defaultTo(false)
table.jsonb('config')
})
// GROUPS ------------------------------
.createTable('groups', table => {
table.increments('id').primary()
@@ -54,6 +71,7 @@ exports.up = knex => {
table.string('path').notNullable()
table.string('title').notNullable()
table.string('description')
table.boolean('isPrivate').notNullable().defaultTo(false)
table.boolean('isPublished').notNullable().defaultTo(false)
table.string('publishStartDate')
table.string('publishEndDate')
@@ -66,9 +84,16 @@ exports.up = knex => {
table.increments('id').primary()
table.string('key').notNullable().unique()
table.jsonb('value')
table.string('createdAt').notNullable()
table.string('updatedAt').notNullable()
})
// STORAGE -----------------------------
.createTable('storage', table => {
table.increments('id').primary()
table.string('key').notNullable().unique()
table.string('title').notNullable()
table.boolean('isEnabled').notNullable().defaultTo(false)
table.jsonb('config')
})
// TAGS --------------------------------
.createTable('tags', table => {
table.increments('id').primary()
@@ -82,16 +107,17 @@ exports.up = knex => {
table.increments('id').primary()
table.string('email').notNullable()
table.string('name').notNullable()
table.string('provider').notNullable().defaultTo('local')
table.string('providerId')
table.string('password')
table.boolean('tfaIsActive').notNullable().defaultTo(false)
table.string('tfaSecret')
table.enum('role', ['admin', 'guest', 'user']).notNullable().defaultTo('guest')
table.string('jobTitle').defaultTo('')
table.string('location').defaultTo('')
table.string('pictureUrl')
table.string('timezone').notNullable().defaultTo('America/New_York')
table.string('createdAt').notNullable()
table.string('updatedAt').notNullable()
table.unique(['provider', 'email'])
})
// =====================================
// RELATION TABLES
@@ -120,11 +146,16 @@ exports.up = knex => {
table.integer('authorId').unsigned().references('id').inTable('users')
})
.table('pages', table => {
table.string('editor').references('key').inTable('editors')
table.string('locale', 2).references('code').inTable('locales')
table.integer('authorId').unsigned().references('id').inTable('users')
})
.table('users', table => {
table.string('locale', 2).references('code').inTable('locales')
table.string('provider').references('key').inTable('authentication').notNullable().defaultTo('local')
table.string('locale', 2).references('code').inTable('locales').notNullable().defaultTo('en')
table.string('defaultEditor').references('key').inTable('editors').notNullable().defaultTo('markdown')
table.unique(['provider', 'email'])
})
}

View File

@@ -0,0 +1,64 @@
const Model = require('objection').Model
const autoload = require('auto-load')
const path = require('path')
const _ = require('lodash')
/* global WIKI */
/**
* Authentication model
*/
module.exports = class Authentication extends Model {
static get tableName() { return 'authentication' }
static get jsonSchema () {
return {
type: 'object',
required: ['key', 'title', 'isEnabled', 'useForm'],
properties: {
id: {type: 'integer'},
key: {type: 'string'},
title: {type: 'string'},
isEnabled: {type: 'boolean'},
useForm: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static async getEnabledStrategies() {
return WIKI.db.authentication.query().where({ isEnabled: true })
}
static async refreshStrategiesFromDisk() {
try {
const dbStrategies = await WIKI.db.authentication.query()
const diskStrategies = autoload(path.join(WIKI.SERVERPATH, 'modules/authentication'))
let newStrategies = []
_.forOwn(diskStrategies, (strategy, strategyKey) => {
if (!_.some(dbStrategies, ['key', strategy.key])) {
newStrategies.push({
key: strategy.key,
title: strategy.title,
isEnabled: false,
useForm: strategy.useForm,
config: _.reduce(strategy.props, (result, value, key) => {
_.set(result, value, '')
return result
}, {})
})
}
})
if (newStrategies.length > 0) {
await WIKI.db.authentication.query().insert(newStrategies)
WIKI.logger.info(`Loaded ${newStrategies.length} new authentication strategies: [ OK ]`)
} else {
WIKI.logger.info(`No new authentication strategies found: [ SKIPPED ]`)
}
} catch (err) {
WIKI.logger.error(`Failed to scan or load new authentication providers: [ FAILED ]`)
WIKI.logger.error(err)
}
}
}

View File

@@ -0,0 +1,62 @@
const Model = require('objection').Model
const autoload = require('auto-load')
const path = require('path')
const _ = require('lodash')
/* global WIKI */
/**
* Editor model
*/
module.exports = class Editor extends Model {
static get tableName() { return 'editors' }
static get jsonSchema () {
return {
type: 'object',
required: ['key', 'title', 'isEnabled'],
properties: {
id: {type: 'integer'},
key: {type: 'string'},
title: {type: 'string'},
isEnabled: {type: 'boolean'},
config: {type: 'object'}
}
}
}
static async getEnabledEditors() {
return WIKI.db.editors.query().where({ isEnabled: true })
}
static async refreshEditorsFromDisk() {
try {
const dbEditors = await WIKI.db.editors.query()
const diskEditors = autoload(path.join(WIKI.SERVERPATH, 'modules/editor'))
let newEditors = []
_.forOwn(diskEditors, (strategy, strategyKey) => {
if (!_.some(dbEditors, ['key', strategy.key])) {
newEditors.push({
key: strategy.key,
title: strategy.title,
isEnabled: false,
config: _.reduce(strategy.props, (result, value, key) => {
_.set(result, value, '')
return result
}, {})
})
}
})
if (newEditors.length > 0) {
await WIKI.db.editors.query().insert(newEditors)
WIKI.logger.info(`Loaded ${newEditors.length} new editors: [ OK ]`)
} else {
WIKI.logger.info(`No new editors found: [ SKIPPED ]`)
}
} catch (err) {
WIKI.logger.error(`Failed to scan or load new editors: [ FAILED ]`)
WIKI.logger.error(err)
}
}
}

View File

@@ -1,9 +1,12 @@
const Model = require('objection').Model
const _ = require('lodash')
/* global WIKI */
/**
* Settings model
*/
module.exports = class User extends Model {
module.exports = class Setting extends Model {
static get tableName() { return 'settings' }
static get jsonSchema () {
@@ -25,7 +28,18 @@ module.exports = class User extends Model {
this.updatedAt = new Date().toISOString()
}
$beforeInsert() {
this.createdAt = new Date().toISOString()
this.updatedAt = new Date().toISOString()
}
static async getConfig() {
const settings = await WIKI.db.settings.query()
if (settings.length > 0) {
return _.reduce(settings, (res, val, key) => {
_.set(res, val.key, (val.value.v) ? val.value.v : val.value)
return res
}, {})
} else {
return false
}
}
}

View File

@@ -30,6 +30,9 @@ module.exports = class User extends Model {
tfaIsActive: {type: 'boolean', default: false},
tfaSecret: {type: 'string'},
locale: {type: 'string'},
jobTitle: {type: 'string'},
location: {type: 'string'},
pictureUrl: {type: 'string'},
createdAt: {type: 'string'},
updatedAt: {type: 'string'}
}

View File

@@ -4,11 +4,10 @@
// ===========================================
const path = require('path')
const cluster = require('cluster')
let WIKI = {
IS_DEBUG: process.env.NODE_ENV === 'development',
IS_MASTER: cluster.isMaster,
IS_MASTER: true,
ROOTPATH: process.cwd(),
SERVERPATH: path.join(process.cwd(), 'server'),
Error: require('./helpers/error'),
@@ -32,18 +31,14 @@ WIKI.logger = require('./core/logger').init('MASTER')
WIKI.telemetry = require('./core/telemetry').init()
process.on('unhandledRejection', (err) => {
WIKI.logger.warn(err)
WIKI.telemetry.sendError(err)
})
process.on('uncaughtException', (err) => {
WIKI.logger.warn(err)
WIKI.telemetry.sendError(err)
})
// ----------------------------------------
// Init DB
// ----------------------------------------
WIKI.db = require('./core/db').init()
// ----------------------------------------
// Start Kernel
// ----------------------------------------

View File

@@ -7,14 +7,15 @@ const { createApolloFetch } = require('apollo-fetch')
WIKI.redis = require('../core/redis').init()
WIKI.db = require('../core/db').init()
const apollo = createApolloFetch({
uri: 'https://graph.requarks.io'
})
module.exports = async (job) => {
WIKI.logger.info(`Fetching locale ${job.data.locale} from Graph endpoint...`)
try {
await WIKI.configSvc.loadFromDb()
const apollo = createApolloFetch({
uri: WIKI.config.graphEndpoint
})
const respStrings = await apollo({
query: `query ($code: String!) {
localization {

View File

@@ -7,15 +7,14 @@ const { createApolloFetch } = require('apollo-fetch')
WIKI.redis = require('../core/redis').init()
WIKI.db = require('../core/db').init()
const apollo = createApolloFetch({
uri: 'https://graph.requarks.io'
})
module.exports = async (job) => {
WIKI.logger.info('Syncing locales with Graph endpoint...')
try {
await WIKI.configSvc.loadFromDb(['site'])
await WIKI.configSvc.loadFromDb()
const apollo = createApolloFetch({
uri: WIKI.config.graphEndpoint
})
// -> Fetch locales list

View File

@@ -75,7 +75,7 @@ module.exports = async () => {
app.use(session({
name: 'wikijs.sid',
store: sessionStore,
secret: WIKI.config.site.sessionSecret,
secret: WIKI.config.sessionSecret,
resave: false,
saveUninitialized: false
}))

View File

@@ -0,0 +1,10 @@
// ------------------------------------
// Markdown Editor (default)
// ------------------------------------
module.exports = {
key: 'markdown',
title: 'Markdown (default)',
props: [],
init (conf) {}
}

View File

@@ -250,8 +250,6 @@ module.exports = () => {
app.post('/finalize', async (req, res) => {
WIKI.telemetry.sendEvent('setup', 'finalize')
console.error('DUDE')
try {
// Upgrade from WIKI.js 1.x?
if (req.body.upgrade) {
@@ -272,41 +270,31 @@ module.exports = () => {
confRaw = yaml.safeDump(conf)
await fs.writeFileAsync(path.join(WIKI.ROOTPATH, 'config.yml'), confRaw)
_.set(WIKI.config, 'port', req.body.port)
// Set config
_.set(WIKI.config, 'defaultEditor', true)
_.set(WIKI.config, 'graphEndpoint', 'https://graph.requarks.io')
_.set(WIKI.config, 'lang', 'en')
_.set(WIKI.config, 'langAutoUpdate', true)
_.set(WIKI.config, 'langRTL', false)
_.set(WIKI.config, 'paths.content', req.body.pathContent)
// Populate config namespaces
WIKI.config.auth = WIKI.config.auth || {}
WIKI.config.features = WIKI.config.features || {}
WIKI.config.logging = WIKI.config.logging || {}
WIKI.config.site = WIKI.config.site || {}
WIKI.config.theme = WIKI.config.theme || {}
WIKI.config.uploads = WIKI.config.uploads || {}
// Site namespace
_.set(WIKI.config.site, 'title', req.body.title)
_.set(WIKI.config.site, 'lang', 'en')
_.set(WIKI.config.site, 'langAutoUpdate', true)
_.set(WIKI.config.site, 'rtl', false)
_.set(WIKI.config.site, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
// Auth namespace
_.set(WIKI.config.auth, 'public', req.body.public === 'true')
_.set(WIKI.config.auth, 'strategies.local.isEnabled', true)
_.set(WIKI.config.auth, 'strategies.local.allowSelfRegister', req.body.selfRegister === 'true')
// Logging namespace
WIKI.config.logging.telemetry = (req.body.telemetry === 'true')
_.set(WIKI.config, 'port', req.body.port)
_.set(WIKI.config, 'public', req.body.public === 'true')
_.set(WIKI.config, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
_.set(WIKI.config, 'telemetry', req.body.telemetry === 'true')
_.set(WIKI.config, 'title', req.body.title)
// Save config to DB
WIKI.logger.info('Persisting config to DB...')
await WIKI.db.settings.query().insert([
{ key: 'auth', value: WIKI.config.auth },
{ key: 'features', value: WIKI.config.features },
{ key: 'logging', value: WIKI.config.logging },
{ key: 'site', value: WIKI.config.site },
{ key: 'theme', value: WIKI.config.theme },
{ key: 'uploads', value: WIKI.config.uploads }
{ key: 'defaultEditor', value: { v: WIKI.config.defaultEditor } },
{ key: 'graphEndpoint', value: { v: WIKI.config.graphEndpoint } },
{ key: 'lang', value: { v: WIKI.config.lang } },
{ key: 'langAutoUpdate', value: { v: WIKI.config.langAutoUpdate } },
{ key: 'langRTL', value: { v: WIKI.config.langRTL } },
{ key: 'public', value: { v: WIKI.config.public } },
{ key: 'sessionSecret', value: { v: WIKI.config.sessionSecret } },
{ key: 'telemetry', value: { v: WIKI.config.telemetry } },
{ key: 'title', value: { v: WIKI.config.title } }
])
// Create default locale
@@ -319,8 +307,20 @@ module.exports = () => {
nativeName: 'English'
})
// Load authentication strategies + enable local
await WIKI.db.authentication.refreshStrategiesFromDisk()
await WIKI.db.authentication.query().patch({ isEnabled: true }).where('key', 'local')
// Load editors + enable default
await WIKI.db.editors.refreshEditorsFromDisk()
await WIKI.db.editors.query().patch({ isEnabled: true }).where('key', 'markdown')
// Create root administrator
WIKI.logger.info('Creating root administrator...')
await WIKI.db.users.query().delete().where({
provider: 'local',
email: req.body.adminEmail
})
await WIKI.db.users.query().insert({
email: req.body.adminEmail,
provider: 'local',
@@ -328,11 +328,12 @@ module.exports = () => {
name: 'Administrator',
role: 'admin',
locale: 'en',
defaultEditor: 'markdown',
tfaIsActive: false
})
// Create Guest account
WIKI.logger.info('Creating root administrator...')
WIKI.logger.info('Creating guest account...')
const guestUsr = await WIKI.db.users.query().findOne({
provider: 'local',
email: 'guest@example.com'
@@ -345,6 +346,7 @@ module.exports = () => {
password: '',
role: 'guest',
locale: 'en',
defaultEditor: 'markdown',
tfaIsActive: false
})
}
@@ -356,6 +358,8 @@ module.exports = () => {
redirectPort: WIKI.config.port
}).end()
WIKI.config.setup = false
WIKI.logger.info('Stopping Setup...')
WIKI.server.destroy(() => {
WIKI.logger.info('Setup stopped. Starting Wiki.js...')
@@ -392,7 +396,7 @@ module.exports = () => {
// Start HTTP server
// ----------------------------------------
WIKI.logger.info(`HTTP Server on port: ${WIKI.config.port}`)
WIKI.logger.info(`HTTP Server on port: [ ${WIKI.config.port} ]`)
app.set('port', WIKI.config.port)
WIKI.server = http.createServer(app)
@@ -433,6 +437,6 @@ module.exports = () => {
})
WIKI.server.on('listening', () => {
WIKI.logger.info('HTTP Server: RUNNING')
WIKI.logger.info('HTTP Server: [ RUNNING ]')
})
}

View File

@@ -1,13 +1,26 @@
extends ./master.pug
block body
body(class='is-error')
.container
a(href='/'): img(src=config.site.path + '/images/logo.png')
h1= message
h2= t('errors:generic')
a.button.is-amber.is-inverted.is-featured(href=config.site.path+ '/')= t('errors:actions.gohome')
if error.stack
h3= t('errors:debugmsg')
pre: code #{error.stack}
#app.is-fullscreen
v-app(dark)
.app-error
v-container
.pt-5
v-layout(row)
v-flex(xs10)
a(href='/'): img(src='/svg/logo-wikijs.svg')
v-flex(xs2).text-xs-right
v-btn(href='/', depressed, color='red darken-3')
v-icon(left) home
span Home
v-alert(color='grey', outline, :value='true', icon='error')
strong.red--text.text--lighten-3 Oops, something went wrong...
.body-1.red--text.text--lighten-2= message
if error.stack
v-expansion-panel.mt-5
v-expansion-panel-content.red.darken-3(:value='true')
div(slot='header') View Debug Trace
v-card(color='grey darken-4')
v-card-text
pre: code #{error.stack}