Skip to content

Commit

Permalink
fixed some bugs, changed the log level of some stuff and removed test…
Browse files Browse the repository at this point in the history
… debugging logs
  • Loading branch information
BrandonSharratt committed Feb 5, 2020
1 parent b17e90f commit 4847971
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
20 changes: 10 additions & 10 deletions microservices/requestApi/clients/formio_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ formio.auth = function(callback){
formio.getSubmissions = function(formName, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName+"/submission";

Expand All @@ -85,7 +85,7 @@ formio.getSubmission = function(formName, submissionId, callback) {

this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName+"/submission/"+submissionId;
logger.verbose("formio get submission", url);
Expand All @@ -106,7 +106,7 @@ formio.getSubmission = function(formName, submissionId, callback) {
formio.postSubmission = function(formName, values, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName+"/submission";

Expand Down Expand Up @@ -139,7 +139,7 @@ formio.postSubmission = function(formName, values, callback) {
formio.deleteSubmission = function(formName, submissionId, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName+"/submission/"+submissionId;

Expand All @@ -156,7 +156,7 @@ formio.deleteSubmission = function(formName, submissionId, callback) {
formio.putSubmission = function(formName, submissionId, values, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName+"/submission/"+submissionId;

Expand All @@ -182,7 +182,7 @@ formio.getForms = function(callback) {
}
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/form";

Expand All @@ -208,7 +208,7 @@ formio.getForm = function(formName, callback) {
}
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/"+formName;

Expand All @@ -229,7 +229,7 @@ formio.getForm = function(formName, callback) {
formio.postForm = function(data, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/form";

Expand All @@ -246,7 +246,7 @@ formio.postForm = function(data, callback) {
formio.putForm = function(formName, data, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/form/" + formName;

Expand All @@ -263,7 +263,7 @@ formio.putForm = function(formName, data, callback) {
formio.deleteForm = function(formName, callback) {
this.auth(function(err, jwt){
if (err){
logger.error("Error getting jwt", err);
logger.debug("Error getting jwt", err);
}
var url = config.get('formio.url') + "/" + formName;

Expand Down
3 changes: 0 additions & 3 deletions microservices/requestApi/routes/routes/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,11 @@ var buildDynamic = function(projectConfig, db, notify, util, router){
return;
}

console.log("TRYING TO SUBMIT", requestId);

// Lookup project from user groups
var project = projectConfig.deriveProjectFromUser(req.user);

db.Request.getAll({_id: requestId}, 1, 1, req.user, function (reqErr, reqRes) {
if (reqErr || !reqRes || reqRes.length == 0) {
console.log("SUBMISSION ERROR", reqErr, reqRes);
res.status(400);
res.json({error: "No Results"});
return;
Expand Down
18 changes: 16 additions & 2 deletions microservices/requestApi/routes/v2/routes/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ var getRouter = function(db){
res.json({error: formErr});
return;
}
res.json(JSON.parse(formRes));
var r = formRes
try{
r = JSON.parse(formRes);
}catch(ex){}

res.status(r.status)
res.json(r);
});
});

Expand All @@ -62,6 +68,7 @@ var getRouter = function(db){
r = JSON.parse(formRes);
}catch(ex){}

res.status(r.status)
res.json(r);
});
});
Expand Down Expand Up @@ -480,7 +487,12 @@ var getRouter = function(db){
res.json({error: formErr});
return;
}
res.json(JSON.parse(formRes));
try{
r = JSON.parse(formRes);
}catch(ex){}

res.status(r.status)
res.json(r);
});
});

Expand All @@ -503,6 +515,7 @@ var getRouter = function(db){
r = JSON.parse(formRes);
}catch(ex){}

res.status(r.status)
res.json(r);
});
});
Expand All @@ -527,6 +540,7 @@ var getRouter = function(db){
r = JSON.parse(formRes);
}catch(ex){}

res.status(r.status)
res.json(r);
});
});
Expand Down
2 changes: 0 additions & 2 deletions microservices/requestApi/test/v2/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ describe("Forms", function() {
.post('/v2/forms')
.set("Authorization", "Bearer "+jwt)
.end(function (err, res) {
console.log("FORM ADMIN", res.status, res.body);
res.should.have.status(403);
res.body.should.have.property('error');
done();
Expand All @@ -730,7 +729,6 @@ describe("Forms", function() {
.set("Authorization", "Bearer "+adminJwt)
.send({})
.end(function (err, res) {
console.log("FORM ADMIN", res.status, res.body);
res.should.have.status(500);
res.body.should.have.property('error');
done();
Expand Down

0 comments on commit 4847971

Please sign in to comment.