-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5081 from FlowFuse/fix-db-views-add-status
Add 3rd Party broker endpoint
- Loading branch information
Showing
2 changed files
with
94 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
module.exports = { | ||
credentials: function (app, credentials) { | ||
const filtered = [] | ||
credentials.forEach(c => { | ||
filtered.push(this.clean(app, c)) | ||
}) | ||
return filtered | ||
}, | ||
clean: function (app, cred) { | ||
const result = cred.toJSON() | ||
const cleaned = { | ||
id: result.hashid, | ||
name: result.name, | ||
host: result.host, | ||
port: result.port, | ||
protocol: result.protocol, | ||
ssl: result.ssl, | ||
verifySSL: result.verifySSL, | ||
clientId: result.clientId | ||
module.exports = function (app) { | ||
app.addSchema({ | ||
$id: 'MQTTBroker', | ||
type: 'object', | ||
properties: { | ||
id: { type: 'string' }, | ||
name: { type: 'string' }, | ||
host: { type: 'string' }, | ||
port: { type: 'number' }, | ||
protocol: { type: 'string' }, | ||
ssl: { type: 'boolean' }, | ||
verifySSL: { type: 'boolean' }, | ||
clientId: { type: 'string' } | ||
}, | ||
additionalProperties: true | ||
}) | ||
return { | ||
clean: function (cred) { | ||
const result = cred.toJSON() | ||
const cleaned = { | ||
id: result.hashid, | ||
name: result.name, | ||
host: result.host, | ||
port: result.port, | ||
protocol: result.protocol, | ||
ssl: result.ssl, | ||
verifySSL: result.verifySSL, | ||
clientId: result.clientId | ||
} | ||
return cleaned | ||
}, | ||
cleanList: function (list) { | ||
const filtered = [] | ||
list.brokers.forEach(u => { | ||
filtered.push(this.clean(u)) | ||
}) | ||
list.brokers = filtered | ||
return list | ||
} | ||
return cleaned | ||
}, | ||
cleanList: function (app, list) { | ||
const filtered = [] | ||
list.brokers.forEach(u => { | ||
filtered.push(this.clean(app, u)) | ||
}) | ||
list.brokers = filtered | ||
return list | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters