62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
import {
|
|
getBlobs,
|
|
createRepCompleteMessage
|
|
} from "../../../actions/azurestorage";
|
|
import { hashAPIPath } from "../../../actions/core/hash";
|
|
import { consoleLogger } from "../../../actions/core/logger";
|
|
|
|
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 filename = req.query.repid;
|
|
var checkHash = req.query.hash;
|
|
|
|
if (
|
|
typeof containerName === "undefined" ||
|
|
containerName.length === 0 ||
|
|
typeof tempCaseRef === "undefined" ||
|
|
tempCaseRef.length === 0 ||
|
|
typeof filename === "undefined" ||
|
|
filename.length === 0 ||
|
|
typeof checkHash === "undefined" ||
|
|
checkHash.length === 0
|
|
) {
|
|
return res.status(400).json();
|
|
}
|
|
|
|
var checkquerypath =
|
|
"/api/file/createrepcompletemessage_api?container=" +
|
|
containerName +
|
|
"&tempcaseref=" +
|
|
tempCaseRef +
|
|
"&repid=" +
|
|
filename;
|
|
|
|
if (hashAPIPath(checkquerypath) != "&hash=" + checkHash) {
|
|
return res.status(400).json();
|
|
}
|
|
|
|
await createRepCompleteMessage(containerName, tempCaseRef, filename)
|
|
.then((data) => {
|
|
return res.status(200).json(data);
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
return res.status(400).json();
|
|
});
|
|
});
|
|
|
|
export const config = {
|
|
api: {
|
|
bodyParser: false
|
|
}
|
|
};
|
|
|
|
export default ApiProxy;
|