multy-stub/server/routers/stc-22-24/utils/common.js

35 lines
510 B
JavaScript
Raw Normal View History

2023-08-01 13:14:02 +03:00
const _idToId = (data) => {
const { _id, ...rest } = data
return {
id: _id,
...rest,
}
}
const _idToIdArray = (data) => {
const _idToIdMap = data.map((item) => _idToId(item))
return _idToIdMap
}
const getResponse = (error, data, success = true) => {
if (error) {
return {
success: false,
error,
}
}
return {
success,
data,
}
}
module.exports = {
getResponse,
_idToIdArray,
_idToId,
}