/** * @swagger * /api/endpoint/getcase_api: * get: * tags: [Case] * summary: Not used * description: Get case * responses: * 200: * description: Success */ import { hasOwn } from "../../../components/utils"; import { respondError } from "../middleware/apiResponse"; import { relayGet } from "../middleware/relayForwarding"; export default async function ApiProxy(req, res) { const incidentID = req.query.incidentID; if (typeof incidentID !== "string" || incidentID.trim().length === 0) { return respondError(res, { status: 400, code: "INCIDENT_ID_REQUIRED", message: "incidentID is required" }); } const queryUrl = "incidents(" + incidentID + ")"; return relayGet({ queryUrl, res, transformData: (data) => { if (hasOwn(data, "@odata.nextLink") === true) { const dataStr = JSON.stringify(data["@odata.nextLink"]); data["@odata.nextLink"] = dataStr.split("/v9.2/")[1]; } return [data]; }, errorResponse: { status: 400, code: "CASE_BY_ID_FETCH_FAILED", message: "Failed to fetch case by id" } }); }