This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/backend/assets/utils/sendResponse.js

11 lines
449 B
JavaScript
Raw Normal View History

2020-03-16 22:55:32 +01:00
/**
* @description Envoie la réponse au client
* @param {Response} res Objet réponse d'une réponse http/express
* @param {Object} object { httpStatus, customProperties{Object}, result }
* @param {Boolean} isSuccess (false par defaut)
2020-03-16 22:55:32 +01:00
*/
function sendResponse (res, object, isSuccess = false) {
res.status(object.httpStatus || 200).json({ isSuccess, ...object.customProperties, result: object.result });
2020-03-16 22:55:32 +01:00
}
module.exports = sendResponse;