68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getwatchedcasesproxy_api:
|
|
* get:
|
|
* tags: [Portal]
|
|
* description: Get my watched cases
|
|
* summary: Phase 2
|
|
* parameters:
|
|
* - name: loggedInUserId
|
|
* in: query
|
|
* required: true
|
|
* example: 726158c6-708d-ec11-aad8-00224800be9c
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Success
|
|
*/
|
|
|
|
import axios from "axios";
|
|
import { azureHeaders } from "../../../actions/core/headers";
|
|
import { consoleLogger } from "../../../actions/core/logger";
|
|
import { getToken } from "../../../actions/core/token";
|
|
import { hashAPIPath } from "../../../actions/core/hash";
|
|
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
|
|
|
const WEBAPI_URL =
|
|
process.env.RELAY_ROOT ||
|
|
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
|
|
const BASE_URL = process.env.API_ROOT || "http://localhost:3000";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
const watchedCaseID = req.query.watchedCaseID;
|
|
|
|
if (
|
|
typeof watchedCaseID !== "string" ||
|
|
watchedCaseID.trim().length === 0
|
|
) {
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "WATCHED_CASE_ID_REQUIRED",
|
|
message: "watchedCaseID is required"
|
|
});
|
|
}
|
|
|
|
try {
|
|
const token = await getToken();
|
|
const queryUrl =
|
|
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" +
|
|
watchedCaseID;
|
|
|
|
const { data } = await axios.get(
|
|
BASE_URL + queryUrl + hashAPIPath(queryUrl),
|
|
azureHeaders(token.access_token)
|
|
);
|
|
|
|
return respondSuccess(res, data);
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "WATCHED_CASE_PROXY_DELETE_FAILED",
|
|
message: "Failed to delete watched case via proxy"
|
|
});
|
|
}
|
|
}
|