added express-promise-wrap to catch and respond to unhandled exceptions immediately, previously the requests just hanged

This commit is contained in:
azivner
2018-01-07 09:35:44 -05:00
parent 20b1357be6
commit 743d72a0c3
26 changed files with 157 additions and 134 deletions

View File

@@ -4,8 +4,9 @@ const express = require('express');
const router = express.Router();
const auth = require('../../services/auth');
const sql = require('../../services/sql');
const wrap = require('express-promise-wrap').wrap;
router.post('/execute', auth.checkApiAuth, async (req, res, next) => {
router.post('/execute', auth.checkApiAuth, wrap(async (req, res, next) => {
const query = req.body.query;
try {
@@ -20,6 +21,6 @@ router.post('/execute', auth.checkApiAuth, async (req, res, next) => {
error: e.message
});
}
});
}));
module.exports = router;