moved alot of stuff from client side
This commit is contained in:
@@ -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 +
|
||||
|
||||
Reference in New Issue
Block a user