parent
d368f8dd7b
commit
2e599971cc
3 changed files with 42 additions and 1 deletions
@ -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'; |
||||
|
Loading…
Reference in new issue