Skip to content
Snippets Groups Projects
Commit 604e05aa authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: proper error catching in node backend

parent 13bbc3bf
No related branches found
No related tags found
No related merge requests found
......@@ -38,9 +38,6 @@ app.use(session({
*/
configureAuth(app)
const catchError = require('./catchError')
app.use(catchError)
const publicPath = process.env.NODE_ENV === 'production'
? path.join(__dirname, 'public')
: path.join(__dirname, '..', 'dist', 'aot')
......@@ -61,4 +58,7 @@ app.use('/nehubaConfig', nehubaConfigRouter)
app.use('/datasets', datasetRouter)
app.use('/plugins', pluginRouter)
const catchError = require('./catchError')
app.use(catchError)
module.exports = app
\ No newline at end of file
......@@ -7,5 +7,5 @@ module.exports = ({code = 500, error = 'an error had occured', trace = 'undefine
error,
trace
})
res.sendStatus(code)
res.status(code).send()
}
\ No newline at end of file
......@@ -18,8 +18,7 @@ datasetsRouter.get('/templateName/:templateName', (req, res, next) => {
const { user } = req
getDatasets({ templateName, user })
.then(ds => {
const data = JSON.stringify(ds)
res.status(200).send(data)
res.status(200).json(ds)
})
.catch(error => {
next({
......@@ -35,7 +34,7 @@ datasetsRouter.get('/parcellationName/:parcellationName', (req, res, next) => {
const { user } = req
getDatasets({ parcellationName, user })
.then(ds => {
res.status(200).send(JSON.stringify(ds))
res.status(200).json(ds)
})
.catch(error => {
next({
......@@ -51,7 +50,7 @@ datasetsRouter.get('/preview/:datasetName', (req, res, next) => {
getPreview({ datasetName })
.then(preview => {
if (preview) {
res.status(200).send(JSON.stringify(preview))
res.status(200).json(preview)
} else {
next({
code: 404,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment