This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/routes/api/task.js

48 lines
928 B
JavaScript

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;