Save version info in app locals

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2019-12-27 15:55:00 +08:00
parent 11265238db
commit 334c81efe7
2 changed files with 6 additions and 7 deletions

4
app.js
View File

@ -206,6 +206,10 @@ app.locals.authProviders = {
email: config.isEmailEnable,
allowEmailRegister: config.allowEmailRegister
}
app.locals.versionInfo = {
latest: true,
versionItem: null
}
// Export/Import menu items
app.locals.enableDropBoxSave = config.isDropboxEnable

View File

@ -8,8 +8,6 @@ const logger = require('../../logger')
const config = require('../../config')
let lastCheckAt
let latest = true
let versionItem = null
const VERSION_CHECK_ENDPOINT = 'https://evangelion.codimd.dev/'
const CHECK_TIMEOUT = 1000 * 60 * 60 * 24 // 1 day
@ -36,8 +34,8 @@ exports.versionCheckMiddleware = async function (req, res, next) {
return next()
}
latest = data.latest
versionItem = latest ? null : data.versionItem
req.app.locals.versionInfo.latest = data.latest
req.app.locals.versionInfo.versionItem = req.app.locals.latest ? null : data.versionItem
return next()
} catch (err) {
@ -47,6 +45,3 @@ exports.versionCheckMiddleware = async function (req, res, next) {
return next()
}
}
exports.versionItem = versionItem
exports.outdated = outdated