mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	
		
			
	
	
		
			19 lines
		
	
	
		
			504 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			19 lines
		
	
	
		
			504 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|  | "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; |