Notes/routes/api/sync.js

17 lines
570 B
JavaScript
Raw Normal View History

2017-10-24 22:58:59 -04:00
"use strict";
const express = require('express');
const router = express.Router();
const sql = require('../../services/sql');
const auth = require('../../services/auth');
2017-10-24 23:14:26 -04:00
router.get('/changed/:since', auth.checkApiAuth, async (req, res, next) => {
const since = parseInt(req.params.since);
2017-10-24 22:58:59 -04:00
2017-10-24 23:14:26 -04:00
res.send({
'tree': await sql.getResults("select * from notes_tree where date_modified >= ?", [since]),
'notes': await sql.getFlattenedResults('note_id', "select note_id from notes where date_modified >= ?", [since])
});
2017-10-24 22:58:59 -04:00
});
module.exports = router;