WIP
This commit is contained in:
parent
c057fe3df8
commit
259b527214
6 changed files with 68 additions and 81 deletions
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
const BigNumber = require('bignumber.js')
|
||||
const logger = require('./logger')
|
||||
const configManager = require('./config-manager')
|
||||
|
||||
let mock = false
|
||||
|
||||
let plugins
|
||||
let lamassuConfig
|
||||
|
||||
module.exports = {
|
||||
init,
|
||||
|
|
@ -56,6 +56,7 @@ function buildBalances () {
|
|||
}
|
||||
|
||||
function poll (req, res) {
|
||||
console.log('DEBUG1')
|
||||
const deviceId = getDeviceId(req)
|
||||
const deviceTime = getDeviceTime(req)
|
||||
const pid = req.query.pid
|
||||
|
|
@ -209,22 +210,11 @@ function verifyTx (req, res) {
|
|||
}
|
||||
|
||||
function pair (req, res) {
|
||||
const token = req.body.token
|
||||
const name = req.body.name
|
||||
// const token = req.body.token
|
||||
// const name = req.body.name
|
||||
|
||||
lamassuConfig.pair(
|
||||
token,
|
||||
getDeviceId(req),
|
||||
name,
|
||||
err => {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
return res.json({err: err.message})
|
||||
}
|
||||
|
||||
res.json({success: true})
|
||||
}
|
||||
)
|
||||
// TODO: Pair
|
||||
res.json({success: true})
|
||||
}
|
||||
|
||||
function phoneCode (req, res) {
|
||||
|
|
@ -323,14 +313,13 @@ function dispense (req, res) {
|
|||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function init (localConfig) {
|
||||
lamassuConfig = localConfig.lamassuConfig
|
||||
plugins = localConfig.plugins
|
||||
mock = localConfig.mock
|
||||
function init (opts) {
|
||||
plugins = opts.plugins
|
||||
mock = opts.mock
|
||||
|
||||
const authMiddleware = localConfig.authMiddleware
|
||||
const app = localConfig.app
|
||||
const localApp = localConfig.localApp
|
||||
const authMiddleware = opts.authMiddleware
|
||||
const app = opts.app
|
||||
const localApp = opts.localApp
|
||||
|
||||
app.get('/poll', authMiddleware, poll)
|
||||
|
||||
|
|
@ -371,6 +360,15 @@ function init (localConfig) {
|
|||
res.sendStatus(200)
|
||||
})
|
||||
|
||||
localApp.post('/dbChange', (req, res) => {
|
||||
return configManager.load()
|
||||
.then(config => {
|
||||
plugins.configure(config)
|
||||
logger.info('Config reloaded')
|
||||
})
|
||||
.catch(logger.error)
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue