feat(striker-ui-api): add /manifest

main
Tsu-ba-me 2 years ago
parent 58371d22b6
commit 6cdca8ee5f
  1. 33
      striker-ui-api/src/lib/request_handlers/manifest/getManifest.ts
  2. 1
      striker-ui-api/src/lib/request_handlers/manifest/index.ts
  3. 2
      striker-ui-api/src/routes/index.ts
  4. 9
      striker-ui-api/src/routes/manifest.ts
  5. 4
      striker-ui-api/src/types/APIManifest.d.ts

@ -0,0 +1,33 @@
import { RequestHandler } from 'express';
import buildGetRequestHandler from '../buildGetRequestHandler';
import { buildQueryResultReducer } from '../../buildQueryResultModifier';
export const getManifest: RequestHandler = buildGetRequestHandler(
(response, buildQueryOptions) => {
const query = `
SELECT
manifest_uuid,
manifest_name
FROM manifests
ORDER BY manifest_name ASC;`;
const afterQueryReturn: QueryResultModifierFunction | undefined =
buildQueryResultReducer<{ [manifestUUID: string]: ManifestOverview }>(
(previous, [manifestUUID, manifestName]) => {
previous[manifestUUID] = {
manifestName,
manifestUUID,
};
return previous;
},
{},
);
if (buildQueryOptions) {
buildQueryOptions.afterQueryReturn = afterQueryReturn;
}
return query;
},
);

@ -7,6 +7,7 @@ import fenceRouter from './fence';
import fileRouter from './file'; import fileRouter from './file';
import hostRouter from './host'; import hostRouter from './host';
import jobRouter from './job'; import jobRouter from './job';
import manifestRouter from './manifest';
import networkInterfaceRouter from './network-interface'; import networkInterfaceRouter from './network-interface';
import serverRouter from './server'; import serverRouter from './server';
import sshKeyRouter from './ssh-key'; import sshKeyRouter from './ssh-key';
@ -21,6 +22,7 @@ const routes: Readonly<Record<string, Router>> = {
file: fileRouter, file: fileRouter,
host: hostRouter, host: hostRouter,
job: jobRouter, job: jobRouter,
manifest: manifestRouter,
'network-interface': networkInterfaceRouter, 'network-interface': networkInterfaceRouter,
server: serverRouter, server: serverRouter,
'ssh-key': sshKeyRouter, 'ssh-key': sshKeyRouter,

@ -0,0 +1,9 @@
import express from 'express';
import { getManifest } from '../lib/request_handlers/manifest';
const router = express.Router();
router.get('/', getManifest);
export default router;

@ -0,0 +1,4 @@
type ManifestOverview = {
manifestName: string;
manifestUUID: string;
};
Loading…
Cancel
Save