mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 18:05:55 +01:00
support for execution of async functions + integration with backend through server.exec()
This commit is contained in:
19
routes/api/script.js
Normal file
19
routes/api/script.js
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const auth = require('../../services/auth');
|
||||
const wrap = require('express-promise-wrap').wrap;
|
||||
const log = require('../../services/log');
|
||||
|
||||
router.post('/exec', auth.checkApiAuth, wrap(async (req, res, next) => {
|
||||
log.info('Executing script: ' + req.body.script);
|
||||
|
||||
const ret = await eval("(" + req.body.script + ")()");
|
||||
|
||||
log.info('Execution result: ' + ret);
|
||||
|
||||
res.send(ret);
|
||||
}));
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user