config endpoint to get device and universe configuration

This commit is contained in:
Max Stockner 2016-10-07 02:44:15 +02:00
parent 4f188f06b3
commit b6a2ff7454

View file

@ -56,6 +56,15 @@ function DMXWeb() {
res.sendfile(__dirname + '/index.html')
})
app.get('/config', function(req, res) {
var response = {"devices": DMX.devices, "universes": {}}
Object.keys(config.universes).forEach(function(key) {
response.universes[key] = config.universes[key].devices
})
res.json(response)
})
app.get('/state/:universe', function(req, res) {
if(!(req.params.universe in dmx.universes)) {
res.status(404).json({"error": "universe not found"})