feat: add operatorId to l-a-s middlewares

fix: make changes to db event handler to receive more complex payloads
feat: machine actions previously on REST now work based on notifications
feat: state middleware now operates based on operatorId as well
chore: remove old localAppRoutes related code
This commit is contained in:
Sérgio Salgado 2021-09-17 16:57:28 +01:00
parent 32e5b1ba87
commit 7135a03654
11 changed files with 71 additions and 78 deletions

View file

@ -6,13 +6,14 @@ function getMachine (machineId) {
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
}
function machineAction ({ deviceId, action, cashbox, cassette1, cassette2, newName }) {
function machineAction ({ deviceId, action, cashbox, cassette1, cassette2, newName }, context) {
const operatorId = context.res.locals.operatorId
return getMachine(deviceId)
.then(machine => {
if (!machine) throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
return machine
})
.then(machineLoader.setMachine({ deviceId, action, cashbox, cassettes: [cassette1, cassette2], newName }))
.then(machineLoader.setMachine({ deviceId, action, cashbox, cassettes: [cassette1, cassette2], newName }, operatorId))
.then(getMachine(deviceId))
}