trilium/routes/api/sql.js

26 lines
591 B
JavaScript
Raw Normal View History

2017-12-15 09:38:56 +08:00
"use strict";
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;
2017-12-15 09:38:56 +08:00
router.post('/execute', auth.checkApiAuth, wrap(async (req, res, next) => {
2017-12-15 09:38:56 +08:00
const query = req.body.query;
try {
res.send({
success: true,
rows: await sql.getAll(query)
});
}
catch (e) {
res.send({
success: false,
error: e.message
});
}
}));
2017-12-15 09:38:56 +08:00
module.exports = router;