feat: core improvements + local fs provider + UI fixes

This commit is contained in:
NGPixel
2018-07-29 22:23:33 -04:00
parent 803d86ff63
commit 2817c72ec3
65 changed files with 482 additions and 264 deletions

View File

@@ -17,7 +17,7 @@ module.exports = {
})
passport.deserializeUser(function (id, done) {
WIKI.db.users.query().findById(id).then((user) => {
WIKI.models.users.query().findById(id).then((user) => {
if (user) {
done(null, user)
} else {
@@ -40,7 +40,7 @@ module.exports = {
_.forEach(currentStrategies, stg => { passport.unuse(stg) })
// Load enabled strategies
const enabledStrategies = await WIKI.db.authentication.getStrategies()
const enabledStrategies = await WIKI.models.authentication.getStrategies()
for (let idx in enabledStrategies) {
const stg = enabledStrategies[idx]
if (!stg.isEnabled) { continue }

View File

@@ -52,7 +52,7 @@ module.exports = {
* Load config from DB
*/
async loadFromDb() {
let conf = await WIKI.db.settings.getConfig()
let conf = await WIKI.models.settings.getConfig()
if (conf) {
WIKI.config = _.defaultsDeep(conf, WIKI.config)
} else {
@@ -73,9 +73,9 @@ module.exports = {
if (!_.isPlainObject(value)) {
value = { v: value }
}
let affectedRows = await WIKI.db.settings.query().patch({ value }).where('key', key)
let affectedRows = await WIKI.models.settings.query().patch({ value }).where('key', key)
if (affectedRows === 0 && value) {
await WIKI.db.settings.query().insert({ key, value })
await WIKI.models.settings.query().insert({ key, value })
}
}
} catch (err) {

View File

@@ -74,7 +74,7 @@ module.exports = {
// Load DB Models
const models = autoload(path.join(WIKI.SERVERPATH, 'db/models'))
const models = autoload(path.join(WIKI.SERVERPATH, 'models'))
// Set init tasks

View File

@@ -6,7 +6,7 @@ module.exports = {
WIKI.logger.info('= Wiki.js =============================')
WIKI.logger.info('=======================================')
WIKI.db = require('./db').init()
WIKI.models = require('./db').init()
WIKI.redis = require('./redis').init()
WIKI.queue = require('./queue').init()
@@ -18,7 +18,7 @@ module.exports = {
*/
async preBootMaster() {
try {
await WIKI.db.onReady
await WIKI.models.onReady
await WIKI.configSvc.loadFromDb()
await WIKI.queue.clean()
} catch (err) {
@@ -48,6 +48,7 @@ module.exports = {
*/
async postBootMaster() {
await WIKI.auth.activateStrategies()
await WIKI.models.storage.refreshTargetsFromDisk()
await WIKI.queue.start()
}
}

View File

@@ -52,7 +52,7 @@ module.exports = {
}
},
async loadLocale(locale, opts = { silent: false }) {
const res = await WIKI.db.locales.query().findOne('code', locale)
const res = await WIKI.models.locales.query().findOne('code', locale)
if (res) {
if (_.isPlainObject(res.strings)) {
_.forOwn(res.strings, (data, ns) => {

View File

@@ -45,7 +45,7 @@ module.exports = {
$not: 'guest'
}
}).toArray()
await WIKI.db.User.bulkCreate(_.map(userData, usr => {
await WIKI.models.User.bulkCreate(_.map(userData, usr => {
return {
email: usr.email,
name: usr.name || 'Imported User',