Add MCP commands route, fix /robots route

This commit is contained in:
Andrew Stewart 2014-07-17 12:08:17 -07:00
parent c97514689b
commit f5734b137e
1 changed files with 7 additions and 2 deletions

View File

@ -49,8 +49,14 @@ router.get("/commands", function(req, res) {
res.json({ commands: Object.keys(Cylon.commands) });
});
router.post("/commands/:command", function(req, res) {
var command = req.params.command;
var result = Cylon.commands[command].apply(Cylon, req.commandParams);
res.json({ result: result });
});
router.get("/robots", function(req, res) {
res.json({ robots: Cylon.robots });
res.json({ robots: Cylon.toJSON().robots });
});
router.get("/robots/:robot", load, function(req, res) {
@ -63,7 +69,6 @@ router.get("/robots/:robot/commands", load, function(req, res) {
router.all("/robots/:robot/commands/:command", load, function(req, res) {
var command = req.params.command;
var result = req.robot[command].apply(req.robot, req.commandParams);
res.json({ result: result });
});