Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade standard to v17 #763

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Brokers that support the [Bridge Protocol][bridge_protocol] can connect to
Aedes. When connecting with this special protocol, subscriptions work as usual
except that the `retain` flag in the packet is propagated as-is.

## Exensions
## Extensions

- [aedes-logging]: Logging module for Aedes, based on Pino
- [aedes-stats]: Stats for Aedes
Expand Down
4 changes: 2 additions & 2 deletions docs/Aedes.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const server = require('net').createServer(aedes.handle)

Directly subscribe a `topic` in server side. Bypass [`authorizeSubscribe`](#handler-authorizesubscribe-client-subscription-callback)

The `topic` and `deliverfunc` is a compound key to differentiate the uniqueness of its subscription pool. `topic` could be the one that is existed, in this case `deliverfunc` will be invoked as well as `SUBSCRIBE` does.
The `topic` and `deliverfunc` is a compound key to differentiate the uniqueness of its subscription pool. `topic` could be the one that is existed, in this case `deliverfunc` will be invoked as well as [`SUBSCRIBE`][SUBSCRIBE] does.

`deliverfunc` supports backpressue.

Expand Down Expand Up @@ -337,7 +337,7 @@ function defaultAuthorizePublish (client, packet, callback) {
Invoked when

1. restore subscriptions in non-clean session.
2. incoming client `SUBSCRIBE`
2. incoming client [`SUBSCRIBE`][SUBSCRIBE]

`subscription` is a dictionary object like `{ topic: hello, qos: 0 }`.

Expand Down
6 changes: 3 additions & 3 deletions lib/handlers/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function init (client, packet, done) {
const error = new Error(errorMessages[returnCode])
error.errorCode = returnCode
doConnack(
{ client: client, returnCode: returnCode, sessionPresent: false },
{ client, returnCode, sessionPresent: false },
done.bind(this, error))
return
}
Expand Down Expand Up @@ -156,8 +156,8 @@ function fetchSubs (arg, done) {
if (!this.packet.clean) {
client.broker.persistence.subscriptionsByClient({
id: client.id,
done: done,
arg: arg
done,
arg
}, gotSubs)
return
}
Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function completeSubscribe (err) {
topic: $SYS_PREFIX + broker.id + '/new/subscribes',
payload: Buffer.from(JSON.stringify({
clientId: client.id,
subs: subs
subs
}), 'utf8')
}, noop)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@
"concat-stream": "^2.0.0",
"duplexify": "^4.1.2",
"license-checker": "^25.0.1",
"markdownlint-cli": "^0.31.1",
"markdownlint-cli": "^0.32.1",
"mqtt": "^4.3.7",
"mqtt-connection": "^4.1.0",
"pre-commit": "^1.2.2",
"proxyquire": "^2.1.3",
"release-it": "^15.1.2",
"snazzy": "^9.0.0",
"standard": "^16.0.4",
"standard": "^17.0.0",
"tap": "^16.0.1",
"tsd": "^0.22.0",
"typescript": "^4.6.3",
Expand Down
8 changes: 4 additions & 4 deletions test/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ test('client connect clear outgoing', function (t) {
const broker = aedes({ id: brokerId })
t.teardown(broker.close.bind(broker))

const subs = [{ clientId: clientId }]
const subs = [{ clientId }]
const packet = {
cmd: 'publish',
topic: 'hello',
payload: Buffer.from('world'),
qos: 1,
brokerId: brokerId,
brokerId,
brokerCounter: 2,
retain: true,
messageId: 42,
Expand All @@ -235,7 +235,7 @@ test('client connect clear outgoing', function (t) {
protocolId: 'MQTT',
protocolVersion: 4,
clean: true,
clientId: clientId,
clientId,
keepalive: 0
})

Expand Down Expand Up @@ -705,7 +705,7 @@ test('websocket clients have access to the request object', function (t) {

const server = http.createServer()
ws.createServer({
server: server
server
}, broker.handle)

server.listen(port, function (err) {
Expand Down
2 changes: 1 addition & 1 deletion test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test('Test backpressure aedes published function', function (t) {

server.listen(0, function () {
const port = server.address().port
publisher = mqtt.connect({ port: port, host: 'localhost', clean: true, keepalive: 30 })
publisher = mqtt.connect({ port, host: 'localhost', clean: true, keepalive: 30 })

function next () {
if (--publishCount > 0) { process.nextTick(publish) }
Expand Down
22 changes: 11 additions & 11 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ function setup (broker) {

return {
client: broker.handle(conn),
conn: conn,
inStream: inStream,
outStream: outStream,
broker: broker
conn,
inStream,
outStream,
broker
}
}

Expand Down Expand Up @@ -74,8 +74,8 @@ function subscribe (t, subscriber, topic, qos, done) {
cmd: 'subscribe',
messageId: 24,
subscriptions: [{
topic: topic,
qos: qos
topic,
qos
}]
})

Expand Down Expand Up @@ -110,10 +110,10 @@ function subscribeMultiple (t, subscriber, subs, expectedGranted, done) {
}

module.exports = {
setup: setup,
connect: connect,
noError: noError,
subscribe: subscribe,
subscribeMultiple: subscribeMultiple,
setup,
connect,
noError,
subscribe,
subscribeMultiple,
delay: util.promisify(setTimeout)
}
2 changes: 1 addition & 1 deletion test/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ test('connect and connackSent event', { timeout: 50 }, function (t) {
protocolId: 'MQTT',
protocolVersion: 4,
clean: true,
clientId: clientId,
clientId,
keepalive: 0
})

Expand Down
10 changes: 5 additions & 5 deletions test/not-blocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('connect 500 concurrent clients', function (t) {

for (let i = 0; i < total; i++) {
clients[i] = mqtt.connect({
port: port,
port,
keepalive: 0,
reconnectPeriod: 100
}).on('connect', function () {
Expand Down Expand Up @@ -79,7 +79,7 @@ test('do not block after a subscription', function (t) {
const port = server.address().port

const publisher = mqtt.connect({
port: port,
port,
keepalive: 0
}).on('error', function (err) {
clock.clearTimeout(clockId)
Expand All @@ -103,7 +103,7 @@ test('do not block after a subscription', function (t) {

function startSubscriber () {
subscriber = mqtt.connect({
port: port,
port,
keepalive: 0
}).on('error', function (err) {
clock.clearTimeout(clockId)
Expand Down Expand Up @@ -163,7 +163,7 @@ test('do not block with overlapping subscription', function (t) {
const port = server.address().port

const publisher = mqtt.connect({
port: port,
port,
keepalive: 0
}).on('error', function (err) {
clock.clearTimeout(clockId)
Expand All @@ -187,7 +187,7 @@ test('do not block with overlapping subscription', function (t) {

function startSubscriber () {
subscriber = mqtt.connect({
port: port,
port,
keepalive: 0
}).on('error', function (err) {
clock.clearTimeout(clockId)
Expand Down
8 changes: 4 additions & 4 deletions test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test('publish invalid topic with +', function (t) {
cmd: 'subscribe',
messageId: 24,
subscriptions: [{
topic: topic,
topic,
qos: 0
}]
})
Expand Down Expand Up @@ -157,7 +157,7 @@ test('topics are case-sensitive', function (t) {
;['hello', 'HELLO', 'heLLo', 'HELLO/#', 'hello/+'].forEach(function (topic) {
publisher.inStream.write({
cmd: 'publish',
topic: topic,
topic,
payload: 'world',
qos: 0,
retain: false
Expand All @@ -171,7 +171,7 @@ function subscribeMultipleTopics (t, broker, qos, subscriber, subscriptions, don
subscriber.inStream.write({
cmd: 'subscribe',
messageId: 24,
subscriptions: subscriptions
subscriptions
})

subscriber.outStream.once('data', function (packet) {
Expand All @@ -183,7 +183,7 @@ function subscribeMultipleTopics (t, broker, qos, subscriber, subscriptions, don
cmd: 'publish',
topic: 'hello/world',
payload: 'world',
qos: qos,
qos,
messageId: 42
})

Expand Down
10 changes: 5 additions & 5 deletions test/will.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test('delivers old will in case of a crash', function (t) {

const interval = 10 // ms, so that the will check happens fast!
const broker = aedes({
persistence: persistence,
persistence,
heartbeatInterval: interval
})
t.teardown(broker.close.bind(broker))
Expand Down Expand Up @@ -121,7 +121,7 @@ test('delete old broker', function (t) {

const heartbeatInterval = 100
const broker = aedes({
heartbeatInterval: heartbeatInterval
heartbeatInterval
})
t.teardown(broker.close.bind(broker))

Expand Down Expand Up @@ -421,7 +421,7 @@ test('don\'t delivers a will if broker alive', function (t) {
t.error(err, 'no error')

const opts = {
persistence: persistence,
persistence,
heartbeatInterval: 10
}

Expand Down Expand Up @@ -472,7 +472,7 @@ test('handle will publish error', function (t) {
t.error(err, 'no error')

const opts = {
persistence: persistence,
persistence,
heartbeatInterval: 10
}

Expand Down Expand Up @@ -509,7 +509,7 @@ test('handle will publish error 2', function (t) {
t.error(err, 'no error')

const opts = {
persistence: persistence,
persistence,
heartbeatInterval: 10
}

Expand Down