You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
676 B
31 lines
676 B
var express = require('express');
|
|
var controller = express.Router();
|
|
var Run = require('../models/runs.js');
|
|
|
|
controller.get('/', function(req, res){
|
|
res.json(runs);
|
|
});
|
|
|
|
controller.get('/:id', function(req, res){
|
|
res.json(runs[req.params.id]);
|
|
});
|
|
|
|
controller.post('/', function(req, res){
|
|
Run.create(req.body).then(function(createdRun){
|
|
//createdRun is the object representation of the row created in the DB
|
|
res.json(createdRun);
|
|
});
|
|
});
|
|
|
|
controller.put('/:id', function(req, res){
|
|
runs[req.params.id] = req.body;
|
|
res.json(runs);
|
|
});
|
|
|
|
controller.delete('/:id', function(req, res){
|
|
runs.splice(req.params.id, 1);
|
|
res.json(runs);
|
|
});
|
|
|
|
module.exports = controller;
|