| 123456789101112131415161718192021222324252627282930313233 |
- const app = require('../app')
- const _ = require('lodash')
- app.run(function(api) {
- api.statistics = () => api.get('/api/statistics')
- let terminals = null
- api.terminals = () => terminals || (terminals = api.get('/api/terminals'))
- let terminalsDictionary = null
- api.terminalsDictionary = () => terminalsDictionary || (terminalsDictionary = api.terminals().then(terminals =>
- _.fromPairs(terminals.map(loc => [loc.key, loc]))
- ))
- api.terminal = (key) => api.terminals().then(async terminals =>
- (await api.terminalsDictionary())[key]
- )
- let staffMembers = null
- api.staffMembers = () => staffMembers || (staffMembers = api.get('/api/staff-members/all'))
- let staffMemberDictionary = null
- api.staffMemberDictionary = () => staffMemberDictionary || (staffMemberDictionary = api.staffMembers().then(staffMembers =>
- _.fromPairs(staffMembers.map(sm => [sm.id, sm]))
- ))
- let clients = null
- api.clients = () => clients || (clients = api.get('/api/clients/all'))
- let clientDictionary = null
- api.clientDictionary = () => clientDictionary || (clientDictionary = api.clients().then(clients =>
- _.fromPairs(clients.map(sm => [sm.id, sm]))
- ))
- })
|