formatting cleanup
This commit is contained in:
parent
b72dca0e2e
commit
4d790feaae
1 changed files with 5 additions and 4 deletions
|
@ -16,29 +16,30 @@ export default async function handler(req, res) {
|
|||
}
|
||||
|
||||
const serviceProxyHandler = widget.proxyHandler || genericProxyHandler;
|
||||
req.method = "GET";
|
||||
|
||||
if (serviceProxyHandler instanceof Function) {
|
||||
// map opaque endpoints to their actual endpoint
|
||||
if (widget?.mappings) {
|
||||
const mapping = widget?.mappings?.[req.query.endpoint];
|
||||
const mappingParams = mapping.params;
|
||||
const mappingParams = mapping?.params;
|
||||
const map = mapping?.map;
|
||||
const endpoint = mapping?.endpoint;
|
||||
const endpointProxy = mapping?.proxyHandler || serviceProxyHandler;
|
||||
req.method = mapping?.method || "GET";
|
||||
|
||||
if (!endpoint) {
|
||||
logger.debug("Unsupported service endpoint: %s", type);
|
||||
return res.status(403).json({ error: "Unsupported service endpoint" });
|
||||
}
|
||||
|
||||
req.method = mapping?.method || "GET";
|
||||
req.query.endpoint = endpoint;
|
||||
|
||||
if (req.query.segments) {
|
||||
const segments = JSON.parse(req.query.segments);
|
||||
req.query.endpoint = formatApiCall(endpoint, segments);
|
||||
}
|
||||
if (req.query.query) {
|
||||
|
||||
if (req.query.query && mappingParams) {
|
||||
const queryParams = JSON.parse(req.query.query);
|
||||
const query = new URLSearchParams(mappingParams.map((p) => [p, queryParams[p]]));
|
||||
req.query.endpoint = `${req.query.endpoint}?${query}`;
|
||||
|
|
Loading…
Add table
Reference in a new issue