This commit is contained in:
Primakov Alexandr Alexandrovich
2024-11-04 18:47:17 +03:00
parent 10dc3e5ffe
commit ef35a8aa6c
12 changed files with 3819 additions and 0 deletions

22
server/utils/common.js Normal file
View File

@@ -0,0 +1,22 @@
const getAnswer = (error, body = null, success = true) => {
if (error) {
return { success: false, error, body }
} else {
return { success, body }
}
}
function cleanId(entity) {
if (Array.isArray(entity)) {
return entity.map(cleanId)
}
const { _id, ...other } = entity;
return { ...other, id: _id };
}
module.exports = {
getAnswer,
cleanId,
}