Skip to content

Instantly share code, notes, and snippets.

@WideWord
Created August 23, 2015 08:35
Show Gist options
  • Save WideWord/fd0cca9d57bb757b7e08 to your computer and use it in GitHub Desktop.
Save WideWord/fd0cca9d57bb757b7e08 to your computer and use it in GitHub Desktop.
module.exports = function(app) {
var express = require('express');
var tasksRouter = express.Router();
var tasks = [
{
id: 0,
description: "kokoko"
},
{
id: 1,
description: "Card 2"
}
];
tasksRouter.get('/', function(req, res) {
res.send({
'tasks': tasks
});
});
tasksRouter.post('/', function(req, res) {
res.status(201).end();
});
tasksRouter.get('/:id', function(req, res) {
res.send({
'tasks': tasks[req.params.id]
});
});
tasksRouter.put('/:id', function(req, res) {
res.send({
'tasks': tasks[req.params.id]
});
});
tasksRouter.delete('/:id', function(req, res) {
res.status(204).end();
});
app.use('/api/tastks', tasksRouter);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment