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

Bump uuid from 9.0.1 to 10.0.0 #82

Merged
merged 2 commits into from
Jun 16, 2024
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 @@ -171,7 +171,7 @@ const arnavmq = require('arnavmq')({
consumerSuffix: '',

// generate a hostname so we can track this connection on the broker (rabbitmq management plugin)
hostname: process.env.HOSTNAME || process.env.USER || uuid.v4(),
hostname: process.env.HOSTNAME || process.env.USER || crypto.randomUUID(),

/**
* A logger object with a log function for each of the log levels ("debug", "info", "warn", or "error").
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"@types/amqplib": "^0.10.5",
"amqplib": "^0.10.3",
"p-defer": "^3.0.0",
"serialize-error": "^8.0.1",
"uuid": "^9.0.0"
"serialize-error": "^8.0.1"
},
"devDependencies": {
"child-process-promise": "^2.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuid = require('uuid');
const crypto = require('crypto');
const connection = require('./modules/connection');
const { setLogger } = require('./modules/logger');

Expand Down Expand Up @@ -28,7 +28,7 @@ module.exports = (config) => {
consumerSuffix: '',

// generate a hostname so we can track this connection on the broker (rabbitmq management plugin)
hostname: process.env.HOSTNAME || process.env.USER || uuid.v4(),
hostname: process.env.HOSTNAME || process.env.USER || crypto.randomUUID(),

...config,
};
Expand Down
4 changes: 2 additions & 2 deletions src/modules/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuid = require('uuid');
const crypto = require('crypto');

function empty() {}

Expand All @@ -19,7 +19,7 @@ function getCorrelationId(options) {
if (options.correlationId) {
return options.correlationId;
}
return uuid.v4();
return crypto.randomUUID();
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions test/config-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const uuid = require('uuid');
const crypto = require('crypto');

/* eslint global-require: "off" */
describe('config', () => {
Expand Down Expand Up @@ -29,7 +29,7 @@ describe('config', () => {
process.env.USER = '';

const conf = { host: 'amqp://localhost' };
assert.equal(main(conf).connection.config.hostname.length, uuid.v4().length);
assert.equal(main(conf).connection.config.hostname.length, crypto.randomUUID().length);
});

it('should ensure prefetch is in an integer format', () => {
Expand Down
16 changes: 8 additions & 8 deletions test/producer-consumer-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const uuid = require('uuid');
const crypto = require('crypto');
const sinon = require('sinon');
const arnavmqConfigurator = require('../src/index');
const utils = require('../src/modules/utils');
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('producer/consumer', function () {
it('should be able to consume message sent by producer to queue [test-queue-0]', async () => {
letters += 1;

await arnavmq.producer.produce(fixtures.queues[0], { msg: uuid.v4() });
await arnavmq.producer.produce(fixtures.queues[0], { msg: crypto.randomUUID() });
await utils.timeoutPromise(300);

assert.equal(letters, 0);
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('producer/consumer', function () {

it('calls the producer "before and after publish" hooks', async () => {
const queueName = 'test-before-after-publish-hooks-queue';
const sentMessage = uuid.v4();
const sentMessage = crypto.randomUUID();

await arnavmq.consumer.consume(queueName, (message) => Promise.resolve(`${message}-test`));
const result = await arnavmq.producer.produce(queueName, sentMessage, { rpc: true });
Expand All @@ -311,7 +311,7 @@ describe('producer/consumer', function () {

it('calls the consumer "before and after process message" hooks', async () => {
const queueName = 'test-before-after-process-message-hooks-queue';
const sentMessage = uuid.v4();
const sentMessage = crypto.randomUUID();

const callback = (message) => Promise.resolve(`${message}-test`);
await arnavmq.consumer.consume(queueName, callback);
Expand All @@ -331,7 +331,7 @@ describe('producer/consumer', function () {

it('calls the consumer "before and after rpc reply" hooks', async () => {
const queueName = 'test-before-after-rpc-hooks-queue';
const sentMessage = uuid.v4();
const sentMessage = crypto.randomUUID();

await arnavmq.consumer.consume(queueName, (message) => Promise.resolve(`${message}-test`));
const result = await arnavmq.producer.produce(queueName, sentMessage, { rpc: true });
Expand Down Expand Up @@ -365,7 +365,7 @@ describe('producer/consumer', function () {

it('does not call unregistered hooks', async () => {
const queueName = 'test-unregister-hooks-queue';
const sentMessage = uuid.v4();
const sentMessage = crypto.randomUUID();

const newHooks = [sinon.spy(), sinon.spy()];
const unregisteredHooks = [
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('producer/consumer', function () {
it('should requeue the message again on error [test-queue-4]', (done) => {
let attempt = 3;

const expectedMessage = { msg: uuid.v4() };
const expectedMessage = { msg: crypto.randomUUID() };
arnavmq.consumer
.consume(fixtures.queues[4], (msg) => {
assert(typeof msg === 'object');
Expand Down Expand Up @@ -468,7 +468,7 @@ describe('producer/consumer', function () {
describe('error', () => {
it('should not be consumed', (done) => {
setupHooks();
const expectedMessage = { msg: uuid.v4() };
const expectedMessage = { msg: crypto.randomUUID() };

arnavmq.consumer
.consume('test-queue-5', () => ({ error: new Error('Error test') }))
Expand Down
6 changes: 3 additions & 3 deletions test/rpc-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const uuid = require('uuid');
const crypto = require('crypto');
const arnavmq = require('../src/index')();
const utils = require('../src/modules/utils');

Expand All @@ -23,14 +23,14 @@ describe('Producer/Consumer RPC messaging:', () => {
});

it('should be able to produce a RPC message and get a response [rpc-queue-0]', async () => {
const response = await arnavmq.producer.produce(fixtures.queues[0], { msg: uuid.v4() }, { rpc: true });
const response = await arnavmq.producer.produce(fixtures.queues[0], { msg: crypto.randomUUID() }, { rpc: true });

assert.strictEqual(response, 'Power Ranger Red');
});

it('should be able to produce a RPC message and get a as JSON [rpc-queue-1]', async () => {
await arnavmq.consumer.consume(fixtures.queues[1], () => ({ powerRangerColor: 'Pink' }));
const response = await arnavmq.producer.produce(fixtures.queues[1], { msg: uuid.v4() }, { rpc: true });
const response = await arnavmq.producer.produce(fixtures.queues[1], { msg: crypto.randomUUID() }, { rpc: true });

assert.strictEqual(typeof response, 'object');
assert.strictEqual(response.powerRangerColor, 'Pink');
Expand Down
Loading