* fix: eslint warnings * refactor: use ramda + sanctuary instead of lodash * refactor: use prettier-standard for formatting * feat: enable security * feat: add graphql * chore: remove trailing commas from linter * docs: new scripts on react and new-admin-server * feat: handle authentication on graphql * fix: perf improvement to date picker * chore: add insecure-dev script to run servers
25 lines
495 B
JavaScript
25 lines
495 B
JavaScript
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 () {
|
|
return db.getState()
|
|
}
|
|
|
|
module.exports = { getConfig, saveConfig }
|