Created
September 15, 2016 17:03
-
-
Save alastaircoote/5aeeb7ea77fc14904ca1220ccfdc2459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trySubscribeAction = function(id, action, log) { | |
return Promise.resolve() | |
.then( () => { | |
if (action == "subscribe") { | |
return subscribePromise(id); | |
} else { | |
return unsubscribePromise(id); | |
} | |
}) | |
.then( (result) => { | |
log.info({result: result}, "Request success"); | |
}) | |
.catch( (error) => { | |
log.error({error: err}, "Request failed"); | |
}) | |
} | |
const subscribe = function(req, res, next) { | |
let deviceId = req.params["id"]; | |
req.log.info({ | |
id: deviceID, | |
action: "subscribe" | |
}, "Received request."); | |
return trySubscribeAction(deviceId, "subscribe"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment