var express = require('express'); var router = express.Router(); /* GET list of tasks */ router.get('/list', function(req, res) { req.getConnection(function(err, connection) { if (err) throw err; var uid = req.session.uid; if ( ! uid) { console.log("Redirect because of bad session in list route"); res.redirect('/'); return; } connection.execute('SELECT * from todo_task_view WHERE user_id=?', [uid], function(err, rows) { if (err) throw err; res.json(rows); }); }); }); /** * Task CRUD */ router.get('/:id', function(req, res) { req.getConnection(function(err, connection) { res.json({}); }); }); router.post('/', function(req, res) { res.send('Error or success message'); }); router.put('/:id', function(req, res) { res.send('Error or success message'); }); router.delete('/:id', function(req, res) { res.send('Error or success message'); }); module.exports = router;