parent
58a867f010
commit
63dafe0e6a
4 changed files with 29 additions and 2 deletions
@ -0,0 +1,20 @@ |
||||
import { DELETED } from '../../consts'; |
||||
|
||||
import { write } from '../../accessModule'; |
||||
import { buildDeleteRequestHandler } from '../buildDeleteRequestHandler'; |
||||
import join from '../../join'; |
||||
|
||||
export const deleteUps = buildDeleteRequestHandler({ |
||||
delete: async (upsUuids) => { |
||||
const wcode = await write( |
||||
`UPDATE upses
|
||||
SET ups_ip_address = '${DELETED}' |
||||
WHERE ups_uuid IN (${join(upsUuids, { |
||||
elementWrapper: "'", |
||||
separator: ',', |
||||
})});`,
|
||||
); |
||||
|
||||
if (wcode !== 0) throw Error(`Write exited with code ${wcode}`); |
||||
}, |
||||
}); |
@ -1,2 +1,3 @@ |
||||
export * from './deleteUps'; |
||||
export * from './getUPS'; |
||||
export * from './getUPSTemplate'; |
||||
|
@ -1,9 +1,12 @@ |
||||
import express from 'express'; |
||||
|
||||
import { getUPS, getUPSTemplate } from '../lib/request_handlers/ups'; |
||||
import { deleteUps, getUPS, getUPSTemplate } from '../lib/request_handlers/ups'; |
||||
|
||||
const router = express.Router(); |
||||
|
||||
router.get('/', getUPS).get('/template', getUPSTemplate); |
||||
router |
||||
.delete('/:uuid?', deleteUps) |
||||
.get('/', getUPS) |
||||
.get('/template', getUPSTemplate); |
||||
|
||||
export default router; |
||||
|
Loading…
Reference in new issue