manager-bh/server/utils/common.js
Primakov Alexandr Alexandrovich ef35a8aa6c init
2024-11-04 18:47:17 +03:00

22 lines
405 B
JavaScript

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,
}