WIP on Threepio changes
This commit is contained in:
parent
4f66bdeb51
commit
6b1d6e2653
|
@ -41,22 +41,24 @@ var load = function load(req, res, next) {
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
router.get("/", function(req, res) {
|
||||||
|
res.json({ MCP: Cylon });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.get("/commands", function(req, res) {
|
||||||
|
res.json({ commands: Object.keys(Cylon.commands) });
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/robots", function(req, res) {
|
router.get("/robots", function(req, res) {
|
||||||
var data = [];
|
res.json({ robots: Cylon.robots });
|
||||||
|
|
||||||
for (var bot in Cylon.robots) {
|
|
||||||
data.push(Cylon.robots[bot]);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json(data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot", load, function(req, res) {
|
router.get("/robots/:robot", load, function(req, res) {
|
||||||
res.json(req.robot);
|
res.json({ robot: req.robot });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/commands", load, function(req, res) {
|
router.get("/robots/:robot/commands", load, function(req, res) {
|
||||||
res.json(req.robot.toJSON().commands);
|
res.json({ commands: req.robot.commands });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.all("/robots/:robot/commands/:command", load, function(req, res) {
|
router.all("/robots/:robot/commands/:command", load, function(req, res) {
|
||||||
|
@ -67,11 +69,11 @@ router.all("/robots/:robot/commands/:command", load, function(req, res) {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/devices", load, function(req, res) {
|
router.get("/robots/:robot/devices", load, function(req, res) {
|
||||||
res.json(req.robot.toJSON().devices);
|
res.json({ devices: req.robot.toJSON().devices });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/devices/:device", load, function(req, res) {
|
router.get("/robots/:robot/devices/:device", load, function(req, res) {
|
||||||
res.json(req.device);
|
res.json({ device: req.device });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/devices/:device/events/:event", load, function(req, res) {
|
router.get("/robots/:robot/devices/:device/events/:event", load, function(req, res) {
|
||||||
|
@ -95,7 +97,7 @@ router.get("/robots/:robot/devices/:device/events/:event", load, function(req, r
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/devices/:device/commands", load, function(req, res) {
|
router.get("/robots/:robot/devices/:device/commands", load, function(req, res) {
|
||||||
res.json(req.device.toJSON().commands);
|
res.json({ commands: req.device.toJSON().commands });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.all("/robots/:robot/devices/:device/commands/:command", load, function(req, res) {
|
router.all("/robots/:robot/devices/:device/commands/:command", load, function(req, res) {
|
||||||
|
@ -106,9 +108,9 @@ router.all("/robots/:robot/devices/:device/commands/:command", load, function(re
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/connections", load, function(req, res) {
|
router.get("/robots/:robot/connections", load, function(req, res) {
|
||||||
res.json(req.robot.toJSON().connections);
|
res.json({ connections: req.robot.toJSON().connections });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/robots/:robot/connections/:connection", load, function(req, res) {
|
router.get("/robots/:robot/connections/:connection", load, function(req, res) {
|
||||||
res.json(req.connection);
|
res.json({ connection: req.connection });
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue