init
This commit is contained in:
22
server/utils/common.js
Normal file
22
server/utils/common.js
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user