chore: server code formatting
This commit is contained in:
parent
aedabcbdee
commit
68517170e2
234 changed files with 9824 additions and 6195 deletions
|
|
@ -1,19 +1,26 @@
|
|||
const machineLoader = require('../../machine-loader')
|
||||
const { UserInputError } = require('../graphql/errors')
|
||||
|
||||
function getMachine (machineId) {
|
||||
return machineLoader.getMachines()
|
||||
function getMachine(machineId) {
|
||||
return machineLoader
|
||||
.getMachines()
|
||||
.then(machines => machines.find(({ deviceId }) => deviceId === machineId))
|
||||
}
|
||||
|
||||
function machineAction ({ deviceId, action, cashUnits, newName }, context) {
|
||||
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 })
|
||||
if (!machine)
|
||||
throw new UserInputError(`machine:${deviceId} not found`, { deviceId })
|
||||
return machine
|
||||
})
|
||||
.then(machineLoader.setMachine({ deviceId, action, cashUnits, newName }, operatorId))
|
||||
.then(
|
||||
machineLoader.setMachine(
|
||||
{ deviceId, action, cashUnits, newName },
|
||||
operatorId,
|
||||
),
|
||||
)
|
||||
.then(getMachine(deviceId))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue