Skip to content

Commit

Permalink
fix: missing handle error coming from express
Browse files Browse the repository at this point in the history
- remove log in `time.js`
  • Loading branch information
Chinlinlee committed Feb 17, 2022
1 parent 5ae3f1b commit 2fe878e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion models/mongodb/FHIRDataTypesSchema/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
if (v) {
let timeDate = moment(v, "hh:mm:ss.SSS").toDate();
let storeTime = timeDate.getHours() * 3600000 + timeDate.getMinutes() * 60000+ timeDate.getSeconds() * 1000 + timeDate.getMilliseconds();
console.log(storeTime);
return storeTime;
}
},
Expand Down
10 changes: 8 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const bodyParser = require('body-parser');
const http = require('http');
const compress = require('compression');
const { handleError } = require('./models/FHIR/httpMessage');
//login
const cookieParser = require('cookie-parser');
const passport = require('passport');
Expand Down Expand Up @@ -37,13 +38,18 @@ app.use((err, req, res, next) => {
// This check makes sure this is a JSON parsing issue, but it might be
// coming from any middleware, not just body-parser:

if (err instanceof SyntaxError && err.status === 400 && 'body' in err) {
// if (err instanceof SyntaxError && err.status === 400 && 'body' in err) {
// console.error(err);
// return res.sendStatus(400); // Bad request
// }
if (err) {
console.error(err);
return res.sendStatus(400); // Bad request
return res.status(400).send(handleError.processing(err));
}

next();
});

app.use(cookieParser());
//login
app.use(session({
Expand Down

0 comments on commit 2fe878e

Please sign in to comment.