Skip to content

Commit 334c81e

Browse files
committed
Save version info in app locals
Signed-off-by: Yukai Huang <[email protected]>
1 parent 1126523 commit 334c81e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ app.locals.authProviders = {
206206
email: config.isEmailEnable,
207207
allowEmailRegister: config.allowEmailRegister
208208
}
209+
app.locals.versionInfo = {
210+
latest: true,
211+
versionItem: null
212+
}
209213

210214
// Export/Import menu items
211215
app.locals.enableDropBoxSave = config.isDropboxEnable

lib/web/middleware/checkVersion.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const logger = require('../../logger')
88
const config = require('../../config')
99

1010
let lastCheckAt
11-
let latest = true
12-
let versionItem = null
1311

1412
const VERSION_CHECK_ENDPOINT = 'https://evangelion.codimd.dev/'
1513
const CHECK_TIMEOUT = 1000 * 60 * 60 * 24 // 1 day
@@ -36,8 +34,8 @@ exports.versionCheckMiddleware = async function (req, res, next) {
3634
return next()
3735
}
3836

39-
latest = data.latest
40-
versionItem = latest ? null : data.versionItem
37+
req.app.locals.versionInfo.latest = data.latest
38+
req.app.locals.versionInfo.versionItem = req.app.locals.latest ? null : data.versionItem
4139

4240
return next()
4341
} catch (err) {
@@ -47,6 +45,3 @@ exports.versionCheckMiddleware = async function (req, res, next) {
4745
return next()
4846
}
4947
}
50-
51-
exports.versionItem = versionItem
52-
exports.outdated = outdated

0 commit comments

Comments
 (0)