Feat: refactor routes.js express entrypoint config
Feat: express config script refactor Feat: add state and settingsCache files
This commit is contained in:
parent
c3f8f98c26
commit
85235eaa13
22 changed files with 807 additions and 1 deletions
35
lib/routes/termsAndConditionsRoutes.js
Normal file
35
lib/routes/termsAndConditionsRoutes.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
const configManager = require('../new-config-manager')
|
||||
const plugins = require('../plugins')
|
||||
|
||||
function createTerms (terms) {
|
||||
if (!terms.active || !terms.text) return null
|
||||
|
||||
return {
|
||||
active: terms.active,
|
||||
title: terms.title,
|
||||
text: nmd(terms.text),
|
||||
accept: terms.acceptButtonText,
|
||||
cancel: terms.cancelButtonText
|
||||
}
|
||||
}
|
||||
|
||||
function getTermsConditions (req, res, next) {
|
||||
const deviceId = req.deviceId
|
||||
const settings = req.settings
|
||||
|
||||
const terms = configManager.getTermsConditions(settings.config)
|
||||
|
||||
const pi = plugins(settings, deviceId)
|
||||
|
||||
return pi.fetchCurrentConfigVersion().then(version => {
|
||||
return res.json({ terms: createTerms(terms), version })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
router.get('/', getTermsConditions)
|
||||
|
||||
module.exports = router
|
||||
Loading…
Add table
Add a link
Reference in a new issue