fix(striker-ui-api): limit UPS types to APC

main
Tsu-ba-me 2 years ago
parent 9bfd5ec672
commit 288597a95f
  1. 16
      striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts

@ -4,7 +4,7 @@ import { getAnvilData } from '../../accessModule';
import { stderr } from '../../shell';
export const getUPSTemplate: RequestHandler = (request, response) => {
let rawUPSData;
let rawUPSData: AnvilDataUPSHash;
try {
({ ups_data: rawUPSData } = getAnvilData<{ ups_data: AnvilDataUPSHash }>(
@ -19,5 +19,17 @@ export const getUPSTemplate: RequestHandler = (request, response) => {
return;
}
response.status(200).send(rawUPSData);
const upsData: AnvilDataUPSHash = Object.entries(
rawUPSData,
).reduce<AnvilDataUPSHash>((previous, [upsTypeId, value]) => {
const { brand } = value;
if (/apc/i.test(brand)) {
previous[upsTypeId] = value;
}
return previous;
}, {});
response.status(200).send(upsData);
};

Loading…
Cancel
Save