Skip to content

Commit aaeafbf

Browse files
committed
Hub to axis
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 3ab9d00 commit aaeafbf

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
Hub: require('./lib/hub')
2+
Axis: require('./lib/axis')
33
}

lib/hub.js renamed to lib/axis.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
const got = require('got')
22
const mqtt = require('mqtt')
33

4-
class Hub {
5-
constructor(apiKey, deviceID, options) {
4+
class Axis {
5+
constructor(apiKey, clientID, options) {
66
this.apiKey = apiKey
7-
this.deviceID = deviceID
7+
this.clientID = clientID
88
this.handlers = {}
99
this.options = options || {}
1010
}
1111

1212
_normalizeDeviceID() {
13-
return `${this.projectID}:${this.deviceID}`
13+
return `${this.projectID}:${this.clientID}`
1414
}
1515

1616
_normalizeTopic(topic) {
@@ -21,9 +21,9 @@ class Hub {
2121
return topic.replace(this.projectID + '/', '');
2222
}
2323

24-
async _findKey() {
24+
async _findProjectID() {
2525
try {
26-
const response = await got('https://api.labstack.com/keys', {
26+
const response = await got('https://api.labstack.com/axis/key', {
2727
headers: {
2828
'Authorization': `Bearer ${this.apiKey}`
2929
},
@@ -37,12 +37,12 @@ class Hub {
3737

3838
async connect(handler) {
3939
try {
40-
await this._findKey()
40+
await this._findProjectID()
4141
} catch (error) {
4242
throw error
4343
}
4444

45-
this.client = mqtt.connect('mqtt://hub.labstack.com', {
45+
this.client = mqtt.connect('mqtt://axis.labstack.com', {
4646
username: this.projectID,
4747
password: this.apiKey,
4848
clientId: this._normalizeDeviceID()
@@ -85,4 +85,4 @@ class Hub {
8585
}
8686
}
8787

88-
module.exports = Hub
88+
module.exports = Axis

0 commit comments

Comments
 (0)