mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 16:20:08 +01:00
added express-promise-wrap to catch and respond to unhandled exceptions immediately, previously the requests just hanged
This commit is contained in:
@@ -5,24 +5,25 @@ const router = express.Router();
|
||||
const sql = require('../../services/sql');
|
||||
const options = require('../../services/options');
|
||||
const auth = require('../../services/auth');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
|
||||
// options allowed to be updated directly in settings dialog
|
||||
const ALLOWED_OPTIONS = ['protected_session_timeout', 'history_snapshot_time_interval'];
|
||||
|
||||
router.get('/all', auth.checkApiAuth, async (req, res, next) => {
|
||||
router.get('/all', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const settings = await sql.getMap("SELECT opt_name, opt_value FROM options");
|
||||
|
||||
res.send(settings);
|
||||
});
|
||||
}));
|
||||
|
||||
router.get('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const settings = await sql.getMap("SELECT opt_name, opt_value FROM options WHERE opt_name IN ("
|
||||
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
|
||||
|
||||
res.send(settings);
|
||||
});
|
||||
}));
|
||||
|
||||
router.post('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
router.post('/', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
const body = req.body;
|
||||
const sourceId = req.headers.source_id;
|
||||
|
||||
@@ -38,6 +39,6 @@ router.post('/', auth.checkApiAuth, async (req, res, next) => {
|
||||
else {
|
||||
res.send("not allowed option to set");
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user