chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
20
packages/server/lib/new-admin/services/machines.js
Normal file
20
packages/server/lib/new-admin/services/machines.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const machineLoader = require('../../machine-loader')
|
||||
const { UserInputError } = require('../graphql/errors')
|
||||
|
||||
function getMachine (machineId) {
|
||||
return machineLoader.getMachines()
|
||||
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
|
||||
}
|
||||
|
||||
function machineAction ({ deviceId, action, cashUnits, 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, cashUnits, newName }, operatorId))
|
||||
.then(getMachine(deviceId))
|
||||
}
|
||||
|
||||
module.exports = { machineAction }
|
||||
Loading…
Add table
Add a link
Reference in a new issue