Feat: implement per operator settings cache
Fix: fix linter-found issues Chore: move findOperatorId to own middleware file Chore: delete old routes.js file and rename new-routes.js to routes.js Fix: PR fixes
This commit is contained in:
parent
85235eaa13
commit
558317e9f3
30 changed files with 232 additions and 860 deletions
25
lib/routes/rootRoutes.js
Normal file
25
lib/routes/rootRoutes.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const express = require('express')
|
||||
const router = express.Router()
|
||||
|
||||
const ca = require('../middlewares/ca')
|
||||
const httpError = require('../route-helpers').httpError
|
||||
const pairing = require('../pairing')
|
||||
const populateDeviceId = require('../middlewares/populateDeviceId')
|
||||
|
||||
function pair (req, res, next) {
|
||||
const token = req.query.token
|
||||
const deviceId = req.deviceId
|
||||
const model = req.query.model
|
||||
|
||||
return pairing.pair(token, deviceId, model)
|
||||
.then(isValid => {
|
||||
if (isValid) return res.json({ status: 'paired' })
|
||||
throw httpError('Pairing failed')
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
router.post('/pair', populateDeviceId, pair)
|
||||
router.get('/ca', ca)
|
||||
|
||||
module.exports = router
|
||||
Loading…
Add table
Add a link
Reference in a new issue