import { hashAPIPath } from "../../../actions"; import { createCaseCompleteMessage, getProgressBlobs, downloadProgressFile, createBlob, } from "../../../actions/azurestorage"; import nextConnect from "next-connect"; import middleware from "../middleware/middleware"; const ApiProxy = nextConnect(); ApiProxy.use(middleware); ApiProxy.get(async (req, res) => { var containerName = req.query.container; var tempCaseRef = req.query.tempcaseref; var checkHash = req.query.hash; console.log("/////Create Case Message:\n", tempCaseRef, "\n//////////////"); // console.log(hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); var checkquerypath = "/api/file/createappealcompletemessage_api?container=" + containerName + "&tempcaseref=" + tempCaseRef; const blobProgress = await getProgressBlobs( containerName, tempCaseRef ).then((data) => { return downloadProgressFile(containerName, data.path, tempCaseRef); }); Object.assign(blobProgress, { "appealComplete": true, }); //http: if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { await createBlob(JSON.stringify(blobProgress), containerName, tempCaseRef) .then(() => { createCaseCompleteMessage(containerName, tempCaseRef); return res.status(200).json({ status: "success", }); }) .catch((error) => { console.log( "///////////////////////\n createCaseCompleteMessage:", error, "///////////////////////\n" ); return res.status(400).json(error); }); // await createCaseCompleteMessage(containerName, tempCaseRef) // .then((data) => { // console.log(data); // createBlob( // JSON.stringify(blobProgress), // containerName, // tempCaseRef // ); // return res.status(200).json(data); // }) // .catch((error) => { // console.log(error); // return res.status(400).json(error); // }); }); export const config = { api: { bodyParser: false, }, }; export default ApiProxy;