Feat: refactor routes.js express entrypoint config
Feat: express config script refactor Feat: add state and settingsCache files
This commit is contained in:
parent
c3f8f98c26
commit
85235eaa13
22 changed files with 807 additions and 1 deletions
20
lib/middlewares/pair.js
Normal file
20
lib/middlewares/pair.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const pairing = require('../pairing')
|
||||
|
||||
function pair (req, res, next) {
|
||||
console.log("pair")
|
||||
const token = req.query.token
|
||||
const deviceId = req.deviceId
|
||||
const model = req.query.model
|
||||
|
||||
return pairing.pair(token, deviceId, model)
|
||||
.then(valid => {
|
||||
if (valid) {
|
||||
return res.json({ status: 'paired' })
|
||||
}
|
||||
|
||||
throw httpError('Pairing failed')
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
module.exports = pair
|
||||
Loading…
Add table
Add a link
Reference in a new issue