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
448 B
JavaScript

/**
* @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)
*/
function sendResponse(res, object, isSuccess = false) {
res.status(object.httpStatus || 200).json({ isSuccess, ...object.customProperties, result: object.result });
}
module.exports = sendResponse;