fix(striker-ui-api): add DELETE one or more manifest

main
Tsu-ba-me 2 years ago
parent d368f8dd7b
commit 2e599971cc
  1. 37
      striker-ui-api/src/lib/request_handlers/manifest/deleteManifest.ts
  2. 1
      striker-ui-api/src/lib/request_handlers/manifest/index.ts
  3. 5
      striker-ui-api/src/routes/manifest.ts

@ -0,0 +1,37 @@
import { RequestHandler } from 'express';
import { sub } from '../../accessModule';
import { stderr, stdout } from '../../shell';
export const deleteManifest: RequestHandler<
{ manifestUuid: string },
undefined,
{ uuids: string[] }
> = (request, response) => {
const {
params: { manifestUuid: rawManifestUuid },
body: { uuids: rawManifestUuidList } = {},
} = request;
const manifestUuidList: string[] = rawManifestUuidList
? rawManifestUuidList
: [rawManifestUuid];
manifestUuidList.forEach((uuid) => {
stdout(`Begin delete manifest ${uuid}.`);
try {
sub('insert_or_update_manifests', {
subParams: { delete: 1, manifest_uuid: uuid },
});
} catch (subError) {
stderr(`Failed to delete manifest ${uuid}; CAUSE: ${subError}`);
response.status(500).send();
return;
}
});
response.status(204).send();
};

@ -1,3 +1,4 @@
export * from './deleteManifest';
export * from './getManifest';
export * from './getManifestDetail';
export * from './getManifestTemplate';

@ -1,6 +1,7 @@
import express from 'express';
import {
deleteManifest,
getManifest,
getManifestDetail,
getManifestTemplate,
@ -11,6 +12,8 @@ const router = express.Router();
router
.get('/', getManifest)
.get('/template', getManifestTemplate)
.get('/:manifestUUID', getManifestDetail);
.get('/:manifestUUID', getManifestDetail)
.delete('/', deleteManifest)
.delete('/manifestUuid', deleteManifest);
export default router;

Loading…
Cancel
Save