Lamassu admin server initial commit

This commit is contained in:
Rafael Taranto 2019-03-12 10:49:09 -03:00 committed by Rafael Taranto
parent d083ae5a40
commit fc1951c4b2
158 changed files with 28462 additions and 1606 deletions

View 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 }