mirror of
https://github.com/zadam/trilium.git
synced 2024-11-11 09:46:25 +08:00
42 lines
No EOL
1 KiB
JavaScript
42 lines
No EOL
1 KiB
JavaScript
"use strict";
|
|
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const auth = require('../../services/auth');
|
|
const sync = require('../../services/sync');
|
|
|
|
router.post('/now', auth.checkApiAuth, async (req, res, next) => {
|
|
const log = await sync.sync();
|
|
|
|
res.send({
|
|
success: true,
|
|
log: log
|
|
});
|
|
});
|
|
|
|
router.get('/changed/:since', auth.checkApiAuth, async (req, res, next) => {
|
|
const since = parseInt(req.params.since);
|
|
|
|
res.send(await sync.getChangedSince(since));
|
|
});
|
|
|
|
router.put('/changed', auth.checkApiAuth, async (req, res, next) => {
|
|
await sync.putChanged(req.body);
|
|
|
|
res.send({});
|
|
});
|
|
|
|
router.get('/note/:noteId/:since', auth.checkApiAuth, async (req, res, next) => {
|
|
const noteId = req.params.noteId;
|
|
const since = parseInt(req.params.since);
|
|
|
|
res.send(await sync.getNoteSince(noteId, since));
|
|
});
|
|
|
|
router.put('/note', auth.checkApiAuth, async (req, res, next) => {
|
|
await sync.putNote(req.body);
|
|
|
|
res.send({});
|
|
});
|
|
|
|
module.exports = router; |