moved alot of stuff from client side

This commit is contained in:
2024-11-18 19:54:23 +00:00
parent 2c5323c9cf
commit e690bc6725
12 changed files with 686 additions and 298 deletions
+43
View File
@@ -109,6 +109,49 @@ export default async function handler(req, res) {
var checkHash = req.query.hash;
let reqBodyobj = req.body; //JSON.parse(req.body);
const cleanFilesList = (blobList) => {
let newblobList = blobList.filesList;
function removeNullObjects(arr) {
if (arr.length === 0) {
return arr;
}
return arr.filter((obj) => obj !== null);
}
function removeObjectsWithUndefinedKey(arr, key) {
if (arr.length === 0) {
return arr;
}
return arr.filter((obj) => obj[key] !== undefined);
}
function removeEmptyObjects(arr) {
if (arr.length === 0) {
return arr;
}
return arr.filter(
(obj) =>
obj &&
typeof obj === "object" &&
Object.keys(obj).length > 0
);
}
newblobList = removeEmptyObjects(newblobList);
newblobList = removeObjectsWithUndefinedKey(newblobList, "name");
newblobList = removeNullObjects(newblobList);
Object.assign(blobList, {
"filesList": newblobList,
});
return blobList;
};
reqBodyobj = reqBodyobj.hasOwnProperty("filesList")
? cleanFilesList(reqBodyobj)
: reqBodyobj;
console.log(
"//////////////////////\nreqBodyobj" +
req +