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
Raw Normal View History

2014-09-23 14:54:05 -04:00
var express = require('express');
var router = express.Router();
/* GET list of tasks */
router.get('/list', function(req, res) {
2014-09-24 17:58:53 -04:00
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);
});
});
2014-09-23 14:54:05 -04:00
});
/**
* 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;