@thecolvinco/nodejs-amqplib
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "@thecolvinco/nodejs-amqplib", | ||
"description": "RabbitMQ abstraction with some utils", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"source": "src/main.ts", | ||
@@ -6,0 +6,0 @@ "main": "dist/main.umd.js", |
@@ -8,3 +8,3 @@ # Colvin nodejs rabbitmq utils | ||
```javascript | ||
import { amqpConnect, retryable, worker, deadLetter } from '@thecolvinco/nodejs-amqplib'; | ||
import { amqpConnect, retryable, worker, deadLetter, toJSON } from '@thecolvinco/nodejs-amqplib'; | ||
@@ -21,6 +21,6 @@ const connectionString = 'amqp://rabbitmq:rabbitmq@localhost:5672'; | ||
return async (msg) => { | ||
console.info(`Message received ${msg}`); | ||
const payload = toJSON(msg).payload; | ||
// Simulate some retryables | ||
if (msg.content.toString() === 'retry') { | ||
if (payload === 'retry') { | ||
await retryable({ | ||
@@ -98,3 +98,3 @@ channel, | ||
```javascript | ||
import { amqpConnect, producer } from '@thecolvinco/nodejs-amqplib'; | ||
import { amqpConnect, producer, createEvent } from '@thecolvinco/nodejs-amqplib'; | ||
@@ -107,5 +107,2 @@ const connectionString = 'amqp://rabbitmq:rabbitmq@localhost:5672'; | ||
const channel = await conn.createChannel(); | ||
const message = args[0] || 'Hello world'; | ||
const key = args[1] || 'blom.superapp.1.event.shopify.order-created'; | ||
const exchange = { | ||
@@ -115,2 +112,14 @@ name: 'blom.exchange.topic', | ||
}; | ||
const messageBody = createEvent({ | ||
payload: args[0] || 'Hello world', | ||
meta: { | ||
company: 'blom', | ||
context: 'superapp', | ||
version: 1, | ||
entity: 'shopify', | ||
name: args[1] || 'order-created', | ||
}, | ||
}); | ||
const key = messageBody.name; | ||
const message = JSON.stringify(messageBody); | ||
@@ -117,0 +126,0 @@ await producer({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72507
144