meshblu-server-websocket
Version:
Websocket Protocol Adapter for Meshblu
26 lines (19 loc) • 665 B
text/coffeescript
_ = require 'lodash'
http = require 'http'
class UpdateHandler
constructor: ({,,,}) ->
do: ([query, params], callback) =>
unless _.isPlainObject params
return callback new Error('invalid update'), 'updated'
_.each params, (value, key) =>
params[key] = _.omit value, ['uuid', 'token']
request =
metadata:
jobType: 'UpdateDevice'
toUuid: query.uuid
auth:
data: params
.do , , request, (error) =>
return callback error, 'update' if error?
callback null, 'updated'
module.exports = UpdateHandler