Fix up various flow issues.

This commit is contained in:
Josh Harvey 2017-09-12 00:00:24 +03:00
parent 08bd7da33f
commit 0d8a8547f5
8 changed files with 60 additions and 40 deletions

View file

@ -188,19 +188,6 @@ function pair (req, res, next) {
.catch(next)
}
function phoneCode (req, res, next) {
const pi = plugins(req.settings, req.deviceId)
const phone = req.body.phone
return pi.getPhoneCode(phone)
.then(code => respond(req, res, {code}))
.catch(err => {
if (err.name === 'BadNumberError') throw httpError('Bad number', 410)
throw err
})
.catch(next)
}
function errorHandler (err, req, res, next) {
const statusCode = err.name === 'HTTPError'
? err.code || 500