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

main
Tsu-ba-me 2 years ago committed by digimer
parent dd6315caf9
commit 2079c6e722
  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 serverRouter from './server';
import sshKeyRouter from './ssh-key';
import upsRouter from './ups';
import userRouter from './user';
const routes: Readonly<Record<string, Router>> = {
@ -23,6 +24,7 @@ const routes: Readonly<Record<string, Router>> = {
'network-interface': networkInterfaceRouter,
server: serverRouter,
'ssh-key': sshKeyRouter,
ups: upsRouter,
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