var express = require('express');
var router = express.Router();
var Bot = require('../models/bot');
var geometry = require('../lib/geometry');
var job = require('../lib/job');

/* GET bots listing. */
router.get('/', function(req, res, next) {
  Bot.find({})
  .then(function(bots) {
    res.send(bots);
  })
  .catch(function(err) {
    res.status(500).err(err);
  });
});

router.post('/', function(req, res, next) {
  var newBot = Bot(req.body);
  newBot.save()
  .then(function(bot) {
    bot.drivers.forEach(function(id_driver) {
      job.driver_new_trip(id_driver);
    });
    res.send(bot);
  })
  .catch(function(err) {
    res.status(500).send(err);
  });
});

router.put('/:id', function(req, res, next) {
  Bot.update({_id: req.params.id}, req.body)
  .then(function(result) {
    res.send();
  })
  .catch(function(err) {
    res.status(500).send(err);
  });
});

router.delete('/:id', function(req, res, next) {
  Bot.remove({ _id: req.params.id })
  .then(function(result) {
    res.send();
  })
  .catch(function(err) {
    res.status(500).send(err);
  });
});

module.exports = router;

@@ -1073,16 +1073,561 @@
 );%0A%7D);%0A%0A
+router.post('/:id/deactivate', function(req, res, next) %7B%0A  Bot.update(%7B_id: req.params.id%7D, %7Bactive: false%7D)%0A  .then(function(result) %7B%0A    res.send();%0A  %7D)%0A  .catch(function(err) %7B%0A    res.status(500).send(err);%0A  %7D);%0A%7D);%0A%0Arouter.post('/:id/active', function(req, res, next) %7B%0A  Bot.findByIdAndUpdate(%7B_id: req.params.id%7D, %7Bactive: true%7D)%0A  .then(function(bot) %7B%0A    bot.drivers.forEach(function(id_driver) %7B%0A      job.driver_new_trip(id_driver);%0A    %7D);%0A    res.send();%0A  %7D)%0A  .catch(function(err) %7B%0A    res.status(500).send(err);%0A  %7D);%0A%7D);%0A%0A
 module.e

Add endpoint to activate and deactivate bot