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

main
Tsu-ba-me 2 years ago
parent 508c7aa1f5
commit f3a2a9355e
  1. 23
      striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts
  2. 1
      striker-ui-api/src/lib/request_handlers/ups/index.ts
  3. 2
      striker-ui-api/src/routes/index.ts
  4. 9
      striker-ui-api/src/routes/ups.ts

@ -0,0 +1,23 @@
import { RequestHandler } from 'express';
import { getAnvilData } from '../../accessModule';
import { stderr } from '../../shell';
export const getUPSTemplate: RequestHandler = (request, response) => {
let rawUPSData;
try {
({ ups_data: rawUPSData } = getAnvilData<{ ups_data: AnvilDataUPSHash }>(
{ ups_data: true },
{ predata: [['Striker->get_ups_data']] },
));
} catch (subError) {
stderr(`Failed to get ups template; CAUSE: ${subError}`);
response.status(500).send();
return;
}
response.status(200).send(rawUPSData);
};

@ -0,0 +1 @@
export * from './getUPSTemplate';

@ -10,6 +10,7 @@ import jobRouter from './job';
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';
import upsRouter from './ups';
import userRouter from './user'; import userRouter from './user';
const routes: Readonly<Record<string, Router>> = { const routes: Readonly<Record<string, Router>> = {
@ -23,6 +24,7 @@ const routes: Readonly<Record<string, Router>> = {
'network-interface': networkInterfaceRouter, 'network-interface': networkInterfaceRouter,
server: serverRouter, server: serverRouter,
'ssh-key': sshKeyRouter, 'ssh-key': sshKeyRouter,
ups: upsRouter,
user: userRouter, user: userRouter,
}; };

@ -0,0 +1,9 @@
import express from 'express';
import { getUPSTemplate } from '../lib/request_handlers/ups';
const router = express.Router();
router.get('/template', getUPSTemplate);
export default router;
Loading…
Cancel
Save