cleaned up some more code
This commit is contained in:
parent
35b8c55966
commit
4dd916997e
1 changed files with 14 additions and 10 deletions
|
@ -64,14 +64,7 @@ function handleRequests() {
|
|||
// POST '/poweroff'
|
||||
app.post('/' + MODE_POWEROFF, (request, response) => {
|
||||
logger.http(request);
|
||||
blinkstick.powerOff(parser.parseRequest(request.body, MODE_POWEROFF))
|
||||
.then((result) => {
|
||||
response.end(JSON.stringify(result));
|
||||
})
|
||||
.catch((err) => {
|
||||
response.status(500);
|
||||
response.end(JSON.stringify({status: 'error', error: err.message}));
|
||||
});
|
||||
handlePowerOff(parser.parseRequest(request.body, MODE_POWEROFF), response);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,8 +72,9 @@ async function handleSimpleAnimation(config, response) {
|
|||
try {
|
||||
response.end(JSON.stringify(await blinkstick.simple(config)));
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
response.status(500);
|
||||
response.end({status: 'error', error: err});
|
||||
response.end(JSON.stringify({status: 'error', error: err.message}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +93,18 @@ async function handleComplexAnimation(config, response) {
|
|||
if (response === undefined) {
|
||||
return;
|
||||
}
|
||||
logger.error(err);
|
||||
response.status(500);
|
||||
response.end({status: 'error', error: err});
|
||||
response.end(JSON.stringify({status: 'error', error: err.message}));
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePowerOff(config, response) {
|
||||
try {
|
||||
response.end(JSON.stringify(await blinkstick.powerOff(config)));
|
||||
} catch (err) {
|
||||
response.status(500);
|
||||
response.end(JSON.stringify({status: 'error', error: err.message}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue