allow endpoint specific maps

This commit is contained in:
Ben Phelps 2022-09-17 08:32:40 +03:00
parent d7be64c3d9
commit 3f17618ad5
2 changed files with 13 additions and 10 deletions

View file

@ -2,7 +2,7 @@ import getServiceWidget from "utils/service-helpers";
import { formatApiCall } from "utils/api-helpers";
import { httpProxy } from "utils/http";
export default async function genericProxyHandler(req, res, mapper) {
export default async function genericProxyHandler(req, res, maps) {
const { group, service, endpoint } = req.query;
if (group && service) {
@ -24,8 +24,8 @@ export default async function genericProxyHandler(req, res, mapper) {
});
let resultData = data;
if (mapper) {
resultData = mapper(endpoint, data);
if (maps[endpoint]) {
resultData = maps[endpoint](data);
}
if (contentType) res.setHeader("Content-Type", contentType);