Merge pull request #15 from bluemaex/master
add config and update endpoints
This commit is contained in:
commit
4a865470d4
1 changed files with 25 additions and 0 deletions
25
dmx-web.js
25
dmx-web.js
|
@ -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"})
|
||||
|
@ -69,6 +78,22 @@ function DMXWeb() {
|
|||
res.json({"state": u})
|
||||
})
|
||||
|
||||
app.post('/state/:universe', function(req, res) {
|
||||
if(!(req.params.universe in dmx.universes)) {
|
||||
res.status(404).json({"error": "universe not found"})
|
||||
return
|
||||
}
|
||||
|
||||
dmx.update(req.params.universe, req.body)
|
||||
|
||||
var universe = dmx.universes[req.params.universe]
|
||||
var u = {}
|
||||
for(var i = 0; i < 256; i++) {
|
||||
u[i] = universe.get(i)
|
||||
}
|
||||
res.json({"state": u})
|
||||
})
|
||||
|
||||
app.post('/animation/:universe', function(req, res) {
|
||||
try {
|
||||
var universe = dmx.universes[req.params.universe]
|
||||
|
|
Loading…
Reference in a new issue