chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
|
|
@ -1,31 +0,0 @@
|
|||
const semver = require('semver')
|
||||
const version = require('../../package.json').version
|
||||
const logger = require('../logger')
|
||||
|
||||
const rejectIncompatibleMachines = function (req, res, next) {
|
||||
const machineVersion = req.query.version
|
||||
const deviceId = req.deviceId
|
||||
|
||||
if (!machineVersion) return next()
|
||||
|
||||
const serverMajor = semver.major(version)
|
||||
const machineMajor = semver.major(machineVersion)
|
||||
|
||||
if (serverMajor - machineMajor > 1) {
|
||||
logger.error(`Machine version too old: ${machineVersion} deviceId: ${deviceId}`)
|
||||
return res.status(400).json({
|
||||
error: 'Machine version too old'
|
||||
})
|
||||
}
|
||||
|
||||
if (serverMajor < machineMajor) {
|
||||
logger.error(`Machine version too new: ${machineVersion} deviceId: ${deviceId}`)
|
||||
return res.status(400).json({
|
||||
error: 'Machine version too new'
|
||||
})
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
module.exports = rejectIncompatibleMachines
|
||||
Loading…
Add table
Add a link
Reference in a new issue