Skip to content

Commit

Permalink
commented out the user create option
Browse files Browse the repository at this point in the history
  • Loading branch information
arunpilli21 committed Aug 10, 2021
1 parent 8b23b65 commit 117af4d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions proxy/proxyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ let error_obj = {
"ver": "1.0",
"ts": "",
"params": {
"resmsgid": "5f36c090-2eee-11eb-80ed-6bb70096c082",
"msgid": "",
"status": "failed",
"err": "",
"errmsg": ""
"resmsgid": "5f36c090-2eee-11eb-80ed-6bb70096c082",
"msgid": "",
"status": "failed",
"err": "",
"errmsg": ""
}
}

Expand All @@ -38,18 +38,18 @@ let error_obj = {
*/
const decorateRequestHeaders = function () {
return function (proxyReqOpts) {
logger.info({message: `adding headers in the request ${proxyReqOpts.path}`});
if (userCreate === proxyReqOpts.path || groupCreate === proxyReqOpts.path) {
logger.info({ message: `adding headers in the request ${proxyReqOpts.path}` });
// if (userCreate === proxyReqOpts.path || groupCreate === proxyReqOpts.path) {
proxyReqOpts.headers.Authorization = 'Bearer ' + Authorization;
}
// }
return proxyReqOpts;
}
}

const decorateRequestHeadersForPutApi = function () {
return function (proxyReqOpts) {
logger.info({message: `Changing the method name for the request ${proxyReqOpts.path}`});
proxyReqOpts.method = 'PUT';
logger.info({ message: `Changing the method name for the request ${proxyReqOpts.path}` });
proxyReqOpts.method = 'PUT';
return proxyReqOpts;
}
}
Expand All @@ -64,7 +64,7 @@ const handleSessionExpiry = (proxyRes, proxyResData, req, res, error) => {
if ((proxyRes.statusCode === 401)) {
edata['message'] = `You are not authorized to access ${req.originalUrl}`;
edata.level = "WARN";
logger.info({message: `You are not authorized to access ${req.originalUrl}`});
logger.info({ message: `You are not authorized to access ${req.originalUrl}` });
logMessage(edata, req);
return {
id: 'app.error',
Expand All @@ -80,14 +80,14 @@ const handleSessionExpiry = (proxyRes, proxyResData, req, res, error) => {
responseCode: 'SESSION_EXPIRED',
result: {}
};
} else if(error || errorStatus.includes(proxyRes.statusCode)) {
} else if (error || errorStatus.includes(proxyRes.statusCode)) {
edata['message'] = `${req.originalUrl} failed`;
logger.info({message: `${req.originalUrl} failed`});
logger.info({ message: `${req.originalUrl} failed` });
logMessage(edata, req);
return errorResponse(req, res,proxyRes, error);
return errorResponse(req, res, proxyRes, error);
} else {
edata['message'] = `${req.originalUrl} successfull`;
logger.info({message: `${req.originalUrl} successfull`});
logger.info({ message: `${req.originalUrl} successfull` });
logMessage(edata, req);
return proxyResData;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ function errorResponse(req, res, proxyRes, error) {
const method = req.method.toLowerCase();
const path = `${req.route.path}.${method}.errorObject`;
const errorObj = _.get(errorCodes, `${path}.${errorCode}`) || _.get(errorCodes, `${path}.${defaultErrorCode}`);
const id = req.originalUrl.split('/');
const id = req.originalUrl.split('/');
error_obj['id'] = id.join('.');
error_obj['ts'] = dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss:lo');
error_obj['params']['msgid'] = req.headers['x-request-id']; // TODO: replace with x-request-id;
Expand All @@ -129,5 +129,5 @@ function errorResponse(req, res, proxyRes, error) {

module.exports.decorateRequestHeaders = decorateRequestHeaders
module.exports.handleSessionExpiry = handleSessionExpiry
module.exports.errorResponse= errorResponse
module.exports.errorResponse = errorResponse
module.exports.decorateRequestHeadersForPutApi = decorateRequestHeadersForPutApi

0 comments on commit 117af4d

Please sign in to comment.