Backend/Microservices/UserService/server/src/Helpers/server.js
/**
    * Method to send the response back to the client.
    * @param responseData: The response data to be send.
    * @param statusCode: The status code that to be send.
    */
Method to send the response back to the client.
@param responseData: The response data to be send.
@param statusCode: The status code that to be send.
Method to send the response back to the client . @param responseData : The response data to be send . @param statusCode : The status code that to be send .
function sendResponse(responseData, statusCode) {
      responseData = validator.validateUndefined(responseData) ? responseData : {};
      statusCode = validator.validateNumber(statusCode) ? statusCode : 500;
      responseData = JSON.stringify(responseData);
      try {
         res.setHeader(constants.CONTENT_TYPE_TEXT, constants.CONTENT_TYPE_JSON);
         res.writeHead(statusCode, constants.HEADERS);
         res.end(responseData);
         printer.printHighlightedLog("RETURNING: " + responseData + "FOR PATH: " + handlerData.path + " with: " + statusCode);
      } catch (e) {
         printer.printError(e);
      }
   }
function sendResponse ( responseData , statusCode ) { responseData = validator . validateUndefined ( responseData ) ? responseData : { } ; statusCode = validator . validateNumber ( statusCode ) ? statusCode : 500 ; responseData = JSON . stringify ( responseData ) ; try { res . setHeader ( constants . CONTENT_TYPE_TEXT , constants . CONTENT_TYPE_JSON ) ; res . writeHead ( statusCode , constants . HEADERS ) ; res . end ( responseData ) ; printer . printHighlightedLog ( "RETURNING: " + responseData + "FOR PATH: " + handlerData . path + " with: " + statusCode ) ; } catch ( e ) { printer . printError ( e ) ; } }
Method to send the response back to the client.
Method to send the response back to the client .