mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
added express-promise-wrap to catch and respond to unhandled exceptions immediately, previously the requests just hanged
This commit is contained in:
@@ -4,14 +4,15 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
const sql = require('../../services/sql');
|
||||
const auth = require('../../services/auth');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
|
||||
router.get('', auth.checkApiAuth, async (req, res, next) => {
|
||||
router.get('', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
await deleteOld();
|
||||
|
||||
const result = await sql.getAll("SELECT * FROM event_log ORDER BY date_added DESC");
|
||||
|
||||
res.send(result);
|
||||
});
|
||||
}));
|
||||
|
||||
async function deleteOld() {
|
||||
const cutoffId = await sql.getFirstValue("SELECT id FROM event_log ORDER BY id DESC LIMIT 1000, 1");
|
||||
|
||||
Reference in New Issue
Block a user