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

main
Tsu-ba-me 2 years ago committed by digimer
parent 882ec15738
commit d408b22f24
  1. 16
      striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts

@ -4,7 +4,7 @@ import { getAnvilData } from '../../accessModule';
import { stderr } from '../../shell'; import { stderr } from '../../shell';
export const getUPSTemplate: RequestHandler = (request, response) => { export const getUPSTemplate: RequestHandler = (request, response) => {
let rawUPSData; let rawUPSData: AnvilDataUPSHash;
try { try {
({ ups_data: rawUPSData } = getAnvilData<{ ups_data: AnvilDataUPSHash }>( ({ ups_data: rawUPSData } = getAnvilData<{ ups_data: AnvilDataUPSHash }>(
@ -19,5 +19,17 @@ export const getUPSTemplate: RequestHandler = (request, response) => {
return; 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