Lamassu admin server initial commit
This commit is contained in:
parent
d083ae5a40
commit
fc1951c4b2
158 changed files with 28462 additions and 1606 deletions
25
lib/new-settings-loader.js
Normal file
25
lib/new-settings-loader.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const _ = require('lodash/fp')
|
||||
const low = require('lowdb')
|
||||
const FileAsync = require('lowdb/adapters/FileAsync')
|
||||
|
||||
const adapter = new FileAsync('db.json')
|
||||
let db = null
|
||||
|
||||
low(adapter).then(it => {
|
||||
db = it
|
||||
})
|
||||
|
||||
function saveConfig (config) {
|
||||
const currentState = db.getState()
|
||||
const newState = _.merge(currentState, config)
|
||||
|
||||
db.setState(newState)
|
||||
return db.write()
|
||||
.then(() => newState)
|
||||
}
|
||||
|
||||
function getConfig (config) {
|
||||
return db.getState()
|
||||
}
|
||||
|
||||
module.exports = { getConfig, saveConfig }
|
||||
Loading…
Add table
Add a link
Reference in a new issue