From 288597a95f9bf987a6cdd6eb6b518bf94813ed77 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 28 Feb 2023 22:32:00 -0500 Subject: [PATCH] fix(striker-ui-api): limit UPS types to APC --- .../lib/request_handlers/ups/getUPSTemplate.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts b/striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts index b966f806..ea014049 100644 --- a/striker-ui-api/src/lib/request_handlers/ups/getUPSTemplate.ts +++ b/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((previous, [upsTypeId, value]) => { + const { brand } = value; + + if (/apc/i.test(brand)) { + previous[upsTypeId] = value; + } + + return previous; + }, {}); + + response.status(200).send(upsData); };