62 lines
1.7 KiB
JavaScript
62 lines
1.7 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 { azureHeaders } from "../../../actions/core/headers";
|
|
import { consoleLogger } from "../../../actions/core/logger";
|
|
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
|
import { forwardGetData } from "../middleware/relayForwarding";
|
|
|
|
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 queryUrl =
|
|
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" +
|
|
watchedCaseID;
|
|
|
|
const { data } = await forwardGetData({
|
|
baseUrl: BASE_URL,
|
|
queryUrl,
|
|
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken)
|
|
});
|
|
|
|
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"
|
|
});
|
|
}
|
|
}
|