mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 12:53:21 +02:00
Fix eslint errors
This commit is contained in:
@@ -23,10 +23,12 @@ function getDevices(req, res) {
|
||||
|
||||
list.forEach(function(device) {
|
||||
datautil.normalize(device, req.user)
|
||||
var responseDevice = device
|
||||
|
||||
if (fields) {
|
||||
device = _.pick(device, fields.split(','))
|
||||
responseDevice = _.pick(device, fields.split(','))
|
||||
}
|
||||
deviceList.push(device)
|
||||
deviceList.push(responseDevice)
|
||||
})
|
||||
|
||||
res.json({
|
||||
@@ -57,13 +59,15 @@ function getDeviceBySerial(req, res) {
|
||||
}
|
||||
|
||||
datautil.normalize(device, req.user)
|
||||
if(fields) {
|
||||
device = _.pick(device, fields.split(','))
|
||||
var responseDevice = device
|
||||
|
||||
if (fields) {
|
||||
responseDevice = _.pick(device, fields.split(','))
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true
|
||||
, device: device
|
||||
, device: responseDevice
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
|
||||
@@ -43,10 +43,11 @@ function getUserDevices(req, res) {
|
||||
|
||||
list.forEach(function(device) {
|
||||
datautil.normalize(device, req.user)
|
||||
var responseDevice = device
|
||||
if (fields) {
|
||||
device = _.pick(device, fields.split(','))
|
||||
responseDevice = _.pick(device, fields.split(','))
|
||||
}
|
||||
deviceList.push(device)
|
||||
deviceList.push(responseDevice)
|
||||
})
|
||||
|
||||
res.json({
|
||||
@@ -84,13 +85,14 @@ function getUserDeviceBySerial(req, res) {
|
||||
})
|
||||
}
|
||||
|
||||
if(fields) {
|
||||
device = _.pick(device, fields.split(','))
|
||||
var responseDevice = device
|
||||
if (fields) {
|
||||
responseDevice = _.pick(device, fields.split(','))
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true
|
||||
, device: device
|
||||
, device: responseDevice
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
@@ -158,9 +160,9 @@ function addUserDevice(req, res) {
|
||||
)
|
||||
, timeout
|
||||
, wireutil.toDeviceRequirements({
|
||||
'serial': {
|
||||
'value': serial
|
||||
, 'match': 'exact'
|
||||
serial: {
|
||||
value: serial
|
||||
, match: 'exact'
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -193,7 +195,6 @@ function deleteUserDeviceBySerial(req, res) {
|
||||
success: false
|
||||
, description: 'You cannot release this device. Not owned by you'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Timer will be called if no JoinGroupMessage is received till 5 seconds
|
||||
@@ -226,9 +227,9 @@ function deleteUserDeviceBySerial(req, res) {
|
||||
, wireutil.envelope(
|
||||
new wire.UngroupMessage(
|
||||
wireutil.toDeviceRequirements({
|
||||
'serial': {
|
||||
'value': serial
|
||||
, 'match': 'exact'
|
||||
serial: {
|
||||
value: serial
|
||||
, match: 'exact'
|
||||
}
|
||||
})
|
||||
)
|
||||
@@ -314,7 +315,6 @@ function remoteDisconnectUserDeviceBySerial(req, res) {
|
||||
|
||||
dbapi.loadDevice(serial)
|
||||
.then(function(device) {
|
||||
|
||||
if (!device) {
|
||||
return res.status(404).json({
|
||||
success: false
|
||||
|
||||
@@ -14,8 +14,8 @@ module.exports = {
|
||||
function accessTokenAuth(req, res, next) {
|
||||
if (req.headers.authorization) {
|
||||
var authHeader = req.headers.authorization.split(' ')
|
||||
, format = authHeader[0]
|
||||
, tokenId = authHeader[1]
|
||||
var format = authHeader[0]
|
||||
var tokenId = authHeader[1]
|
||||
|
||||
if (format !== 'Bearer') {
|
||||
return res.status(401).json({
|
||||
@@ -42,7 +42,7 @@ function accessTokenAuth(req, res, next) {
|
||||
}
|
||||
|
||||
var jwt = token.jwt
|
||||
, data = jwtutil.decode(jwt, req.options.secret)
|
||||
var data = jwtutil.decode(jwt, req.options.secret)
|
||||
|
||||
if (!data) {
|
||||
return res.status(500).json({
|
||||
@@ -54,7 +54,8 @@ function accessTokenAuth(req, res, next) {
|
||||
if (user) {
|
||||
req.user = user
|
||||
next()
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return res.status(500).json({
|
||||
success: false
|
||||
})
|
||||
|
||||
@@ -16,9 +16,9 @@ var wireutil = require('../../wire/util')
|
||||
|
||||
module.exports = function(options) {
|
||||
var log = logger.createLogger('api')
|
||||
, app = express()
|
||||
, server = http.createServer(app)
|
||||
, channelRouter = new events.EventEmitter()
|
||||
var app = express()
|
||||
var server = http.createServer(app)
|
||||
var channelRouter = new events.EventEmitter()
|
||||
|
||||
var push = zmqutil.socket('push')
|
||||
Promise.map(options.endpoints.push, function(endpoint) {
|
||||
@@ -30,7 +30,7 @@ module.exports = function(options) {
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(function(err) {w
|
||||
.catch(function(err) {
|
||||
log.fatal('Unable to connect to push endpoint', err)
|
||||
lifecycle.fatal()
|
||||
})
|
||||
@@ -65,22 +65,22 @@ module.exports = function(options) {
|
||||
var config = {
|
||||
appRoot: __dirname
|
||||
, swaggerFile: path.resolve(__dirname, 'swagger', 'api_v1.yaml')
|
||||
};
|
||||
}
|
||||
|
||||
SwaggerExpress.create(config, function(err, swaggerExpress) {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
swaggerExpress.register(app);
|
||||
swaggerExpress.register(app)
|
||||
})
|
||||
|
||||
// Adding options in request, so that swagger controller
|
||||
// can use it.
|
||||
app.use(function(req, res, next) {
|
||||
var reqOptions = _.merge(options, {
|
||||
'push': push
|
||||
, 'sub': sub
|
||||
, 'channelRouter': channelRouter
|
||||
push: push
|
||||
, sub: sub
|
||||
, channelRouter: channelRouter
|
||||
})
|
||||
|
||||
req.options = reqOptions
|
||||
|
||||
Reference in New Issue
Block a user