remove some unnecessary method calls
This commit is contained in:
parent
1a52bc31e7
commit
4dca1d43b0
1 changed files with 3 additions and 7 deletions
|
@ -85,24 +85,20 @@ function handleRequests() {
|
|||
// POST methods
|
||||
app.post('*', function (request, response) {
|
||||
logger.logRequest(request);
|
||||
if (!blinkstick.isAnimationInProgress() || blinkstick.isInfiniteAnimationInProgress()) {
|
||||
response.end();
|
||||
blinkstick.parseColor(parseRequest(request.body))
|
||||
.then(blinkstick.illuminate)
|
||||
blinkstick.illuminate(parseRequest(request.body))
|
||||
.then(logger.info)
|
||||
.catch(logger.error);
|
||||
return;
|
||||
}
|
||||
response.sendStatus(503);
|
||||
});
|
||||
}
|
||||
|
||||
// parse the request and return an object with sane defaults
|
||||
function parseRequest(data) {
|
||||
const blinkstickConfig = {
|
||||
let blinkstickConfig = {
|
||||
"id": Math.random(),
|
||||
"mode": data["mode"] || config.api.post.mode.default,
|
||||
"color": data["color"] || config.api.post.color.default,
|
||||
"color": blinkstick.parseColor(data["color"]),
|
||||
"options": {
|
||||
"duration": data["duration"] || config.api.post.duration.default,
|
||||
"pulse": {
|
||||
|
|
Loading…
Reference in a new issue