Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Enable useArrowFunction lint rule to prefer arrow functions for cleaner syntax
- Enable noUselessCatch lint rule to prevent useless catch blocks that only rethrow errors
- Enable noArguments rule to enforce modern rest parameters instead of legacy arguments object
- Enable bracketSpacing formatting rule to add spaces inside object literals

## v0.10.9
- Add support for IPv6 urls
Expand Down
4 changes: 2 additions & 2 deletions bin/generate-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function initial(part) {
function argument(a) {
const type = a.type || domains[a.domain];
const friendlyName = propertyName(a.name);
return {type: type, name: friendlyName, default: a['default-value']};
return { type: type, name: friendlyName, default: a['default-value'] };
}

const domains = {};
Expand Down Expand Up @@ -529,7 +529,7 @@ function decoderFn(method) {
}

function infoObj(thing) {
const info = JSON.stringify({id: thing.id, classId: thing.clazzId, methodId: thing.methodId, name: thing.name, args: thing.args});
const info = JSON.stringify({ id: thing.id, classId: thing.clazzId, methodId: thing.methodId, name: thing.name, args: thing.args });
println('var %s = module.exports.%s = %s;', thing.info, thing.info, info);
}

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"formatter": {
"arrowParentheses": "always",
"bracketSameLine": false,
"bracketSpacing": false,
"bracketSpacing": true,
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"quoteStyle": "single",
Expand Down
4 changes: 2 additions & 2 deletions examples/direct_reply_to_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const queue = 'rpc_queue';
await channel.close();
await connection.close();
},
{noAck: true},
{ noAck: true },
);

await channel.assertQueue(queue, {durable: false});
await channel.assertQueue(queue, { durable: false });

channel.sendToQueue(queue, Buffer.from(' [X] ping'), {
replyTo: 'amq.rabbitmq.reply-to',
Expand Down
4 changes: 2 additions & 2 deletions examples/direct_reply_to_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const queue = 'rpc_queue';
await connection.close();
});

await channel.assertQueue(queue, {durable: false});
await channel.assertQueue(queue, { durable: false });
await channel.consume(
queue,
(message) => {
console.log(message.content.toString());
channel.sendToQueue(message.properties.replyTo, Buffer.from(' [.] pong'));
},
{noAck: true},
{ noAck: true },
);

console.log(' [x] To exit press CTRL+C.');
Expand Down
12 changes: 6 additions & 6 deletions examples/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const amqp = require('../');
await connection.close();
});

const {exchange} = await channel.assertExchange('matching exchange', 'headers');
const {queue} = await channel.assertQueue();
const { exchange } = await channel.assertExchange('matching exchange', 'headers');
const { queue } = await channel.assertQueue();

// When using a headers exchange, the headers to be matched go in
// the binding arguments. The routing key is ignore, so best left
Expand All @@ -32,12 +32,12 @@ const amqp = require('../');
(message) => {
console.log(message.content.toString());
},
{noAck: true},
{ noAck: true },
);

channel.publish(exchange, '', Buffer.from('hello'), {headers: {baz: 'boo'}});
channel.publish(exchange, '', Buffer.from('hello'), {headers: {foo: 'bar'}});
channel.publish(exchange, '', Buffer.from('lost'), {headers: {meh: 'nah'}});
channel.publish(exchange, '', Buffer.from('hello'), { headers: { baz: 'boo' } });
channel.publish(exchange, '', Buffer.from('hello'), { headers: { foo: 'bar' } });
channel.publish(exchange, '', Buffer.from('lost'), { headers: { meh: 'nah' } });

console.log(' [x] To exit press CTRL+C.');
})();
2 changes: 1 addition & 1 deletion examples/receive_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ co(function* () {
channel.sendToQueue(q, Buffer.from(msg));
console.log(" [x] Sent '%s'", msg);
// consume the message
yield channel.consume(q, myConsumer, {noAck: true});
yield channel.consume(q, myConsumer, { noAck: true });
}).catch((err) => {
console.warn('Error:', err);
});
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/emit_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertExchange(exchange, 'fanout', {durable: false}, (err) => {
channel.assertExchange(exchange, 'fanout', { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.publish(exchange, '', Buffer.from(text));
console.log(" [x] Sent '%s'", text);
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/emit_log_direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertExchange(exchange, 'direct', {durable: false}, (err) => {
channel.assertExchange(exchange, 'direct', { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.publish(exchange, routingKey, Buffer.from(text));
console.log(" [x] Sent '%s'", text);
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/emit_log_topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertExchange(exchange, 'topic', {durable: false}, (err) => {
channel.assertExchange(exchange, 'topic', { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.publish(exchange, routingKey, Buffer.from(text));
console.log(" [x] Sent '%s'", text);
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/callback_api/new_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertQueue(queue, {durable: true}, (err) => {
channel.assertQueue(queue, { durable: true }, (err) => {
if (err) return bails(err, connection);
channel.sendToQueue(queue, Buffer.from(text), {persistent: true});
channel.sendToQueue(queue, Buffer.from(text), { persistent: true });
console.log(" [x] Sent '%s'", text);
channel.close(() => {
connection.close();
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/callback_api/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ amqp.connect((err, connection) => {
});
});

channel.assertQueue(queue, {durable: false}, (err) => {
channel.assertQueue(queue, { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.consume(
queue,
(message) => {
if (message) console.log(" [x] Received '%s'", message.content.toString());
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
{ noAck: true },
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/callback_api/receive_logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ amqp.connect((err, connection) => {
});
});

channel.assertExchange(exchange, 'fanout', {durable: false}, (err, {queue: _queue}) => {
channel.assertExchange(exchange, 'fanout', { durable: false }, (err, { queue: _queue }) => {
if (err) return bail(err, connection);
channel.assertQueue('', {exclusive: true}, (err, {queue}) => {
channel.assertQueue('', { exclusive: true }, (err, { queue }) => {
if (err) return bail(err, connection);
channel.bindQueue(queue, exchange, '', {}, (err) => {
if (err) return bail(err, connection);
Expand All @@ -27,7 +27,7 @@ amqp.connect((err, connection) => {
if (message) console.log(" [x] '%s'", message.content.toString());
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
{ noAck: true },
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/callback_api/receive_logs_direct.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

const amqp = require('amqplib/callback_api');
const {basename} = require('node:path');
const { basename } = require('node:path');

const exchange = 'direct_logs';
const severities = process.argv.slice(2);
Expand All @@ -21,17 +21,17 @@ amqp.connect((err, connection) => {
});
});

channel.assertExchange(exchange, 'direct', {durable: false}, (err) => {
channel.assertExchange(exchange, 'direct', { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.assertQueue('', {exclusive: true}, (err, {queue}) => {
channel.assertQueue('', { exclusive: true }, (err, { queue }) => {
if (err) return bail(err, connection);
channel.consume(
queue,
(message) => {
if (message) console.log(" [x] %s:'%s'", message.fields.routingKey, message.content.toString());
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
{ noAck: true },
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/callback_api/receive_logs_topic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

const amqp = require('amqplib/callback_api');
const {basename} = require('node:path');
const { basename } = require('node:path');

const exchange = 'topic_logs';
const severities = process.argv.slice(2);
Expand All @@ -21,17 +21,17 @@ amqp.connect((err, connection) => {
});
});

channel.assertExchange(exchange, 'topic', {durable: false}, (err) => {
channel.assertExchange(exchange, 'topic', { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.assertQueue('', {exclusive: true}, (err, {queue}) => {
channel.assertQueue('', { exclusive: true }, (err, { queue }) => {
if (err) return bail(err, connection);
channel.consume(
queue,
(message) => {
if (message) console.log(" [x] %s:'%s'", message.fields.routingKey, message.content.toString());
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
{ noAck: true },
(err) => {
if (err) return bail(err, connection);
console.log(' [*] Waiting for logs. To exit press CTRL+C.');
Expand Down
10 changes: 5 additions & 5 deletions examples/tutorials/callback_api/rpc_client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

const amqp = require('amqplib/callback_api');
const {basename} = require('node:path');
const {v4: uuid} = require('uuid');
const { basename } = require('node:path');
const { v4: uuid } = require('uuid');

const queue = 'rpc_queue';

Expand All @@ -16,7 +16,7 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertQueue('', {exclusive: true}, (err, {queue: replyTo}) => {
channel.assertQueue('', { exclusive: true }, (err, { queue: replyTo }) => {
if (err) return bail(err, connection);

const correlationId = uuid();
Expand All @@ -31,10 +31,10 @@ amqp.connect((err, connection) => {
});
}
},
{noAck: true},
{ noAck: true },
);

channel.assertQueue(queue, {durable: false}, (err) => {
channel.assertQueue(queue, { durable: false }, (err) => {
if (err) return bail(err, connection);
console.log(' [x] Requesting fib(%d)', n);
channel.sendToQueue(queue, Buffer.from(n.toString()), {
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/callback_api/rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ amqp.connect((err, connection) => {
});
});

channel.assertQueue(queue, {durable: false}, (err) => {
channel.assertQueue(queue, { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.prefetch(1);
channel.consume(
Expand All @@ -29,7 +29,7 @@ amqp.connect((err, connection) => {
});
channel.ack(message);
},
{noAck: false},
{ noAck: false },
(err) => {
if (err) return bail(err, conn);
console.log(' [x] Awaiting RPC requests. To exit press CTRL+C.');
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/callback_api/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ amqp.connect((err, connection) => {
if (err) return bail(err);
connection.createChannel((err, channel) => {
if (err) return bail(err, connection);
channel.assertQueue(queue, {durable: false}, (err) => {
channel.assertQueue(queue, { durable: false }, (err) => {
if (err) return bail(err, connection);
channel.sendToQueue(queue, Buffer.from(text));
console.log(" [x] Sent '%s'", text);
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/callback_api/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ amqp.connect((err, connection) => {
});
});

channel.assertQueue(queue, {durable: true}, (err, {queue}) => {
channel.assertQueue(queue, { durable: true }, (err, { queue }) => {
if (err) return bail(err, connection);
channel.consume(
queue,
Expand All @@ -28,7 +28,7 @@ amqp.connect((err, connection) => {
channel.ack(message);
}, seconds * 1000);
},
{noAck: false},
{ noAck: false },
);
console.log(' [*] Waiting for messages. To exit press CTRL+C');
});
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/emit_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const text = process.argv.slice(2).join(' ') || 'info: Hello World!';
try {
connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
await channel.assertExchange(exchange, 'fanout', {durable: false});
await channel.assertExchange(exchange, 'fanout', { durable: false });
channel.publish(exchange, '', Buffer.from(text));
console.log(" [x] Sent '%s'", text);
await channel.close();
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/emit_log_direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const text = args.slice(1).join(' ') || 'Hello World!';
try {
connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
await channel.assertExchange(exchange, 'direct', {durable: false});
await channel.assertExchange(exchange, 'direct', { durable: false });
channel.publish(exchange, routingKey, Buffer.from(text));
console.log(" [x] Sent %s:'%s'", routingKey, text);
await channel.close();
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/emit_log_topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const text = args.slice(1).join(' ') || 'Hello World!';
try {
connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
await channel.assertExchange(exchange, 'topic', {durable: false});
await channel.assertExchange(exchange, 'topic', { durable: false });
channel.publish(exchange, routingKeys, Buffer.from(text));
console.log(" [x] Sent %s:'%s'", routingKeys, text);
await channel.close();
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/new_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const text = process.argv.slice(2).join(' ') || 'Hello World!';
try {
connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
await channel.assertQueue(queue, {durable: true});
channel.sendToQueue(queue, Buffer.from(text), {persistent: true});
await channel.assertQueue(queue, { durable: true });
channel.sendToQueue(queue, Buffer.from(text), { persistent: true });
console.log(" [x] Sent '%s'", text);
await channel.close();
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const queue = 'hello';
await connection.close();
});

await channel.assertQueue(queue, {durable: false});
await channel.assertQueue(queue, { durable: false });
await channel.consume(
queue,
(message) => {
console.log(" [x] Received '%s'", message.content.toString());
},
{noAck: true},
{ noAck: true },
);

console.log(' [*] Waiting for messages. To exit press CTRL+C');
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/receive_logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const exchange = 'logs';
await connection.close();
});

await channel.assertExchange(exchange, 'fanout', {durable: false});
const {queue} = await channel.assertQueue('', {exclusive: true});
await channel.assertExchange(exchange, 'fanout', { durable: false });
const { queue } = await channel.assertQueue('', { exclusive: true });
await channel.bindQueue(queue, exchange, '');

await channel.consume(
Expand All @@ -24,7 +24,7 @@ const exchange = 'logs';
if (message) console.log(" [x] '%s'", message.content.toString());
else console.warn(' [x] Consumer cancelled');
},
{noAck: true},
{ noAck: true },
);

console.log(' [*] Waiting for logs. To exit press CTRL+C');
Expand Down
Loading