first experiments with code mirror

This commit is contained in:
azivner
2018-01-20 21:56:03 -05:00
parent 93b4cf6a05
commit 090e1b845f
9 changed files with 82 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ const utils = require('../../services/utils');
const protected_session = require('../../services/protected_session');
const data_encryption = require('../../services/data_encryption');
const tree = require('../../services/tree');
const sync_table = require('../../services/sync_table');
const wrap = require('express-promise-wrap').wrap;
router.get('/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
@@ -92,4 +93,19 @@ router.put('/:noteId/protect-sub-tree/:isProtected', auth.checkApiAuth, wrap(asy
res.send({});
}));
router.put('/:noteId/type/:type', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteId = req.params.noteId;
const type = req.params.type;
const sourceId = req.headers.source_id;
await sql.doInTransaction(async () => {
await sql.execute("UPDATE notes SET type = ?, date_modified = ? WHERE note_id = ?",
[type, utils.nowDate(), noteId]);
await sync_table.addNoteSync(noteId, sourceId);
});
res.send({});
}));
module.exports = router;