@pager/event-sourcerer-client
Advanced tools
Comparing version 3.0.0 to 3.1.1
'use strict'; | ||
const Uuid = require('uuid/v4'); | ||
const { v4: Uuid } = require('uuid'); | ||
const Joi = require('@hapi/joi'); | ||
@@ -15,2 +15,10 @@ | ||
static default(publisher, idGenerator = Uuid) { | ||
const SingleKeyRabbit = require('./transports/single-key-rabbit'); | ||
const defaultTransport = new SingleKeyRabbit(publisher); | ||
return new Client(defaultTransport, idGenerator); | ||
} | ||
addPrePublishValidator(stream, eventType, validationSchema) { | ||
@@ -17,0 +25,0 @@ |
@@ -11,3 +11,3 @@ 'use strict'; | ||
publish(stream, streamId, eventType, data, asOf) { | ||
publish(stream, streamId, eventType, data) { | ||
@@ -14,0 +14,0 @@ return this.publisher.publish(data, { |
{ | ||
"name": "@pager/event-sourcerer-client", | ||
"version": "3.0.0", | ||
"version": "3.1.1", | ||
"description": "event-sourcerer client", | ||
@@ -19,3 +19,3 @@ "main": "lib/index.js", | ||
"@pager/logger": "5.x", | ||
"uuid": "3.x" | ||
"uuid": "7.x" | ||
}, | ||
@@ -27,3 +27,3 @@ "devDependencies": { | ||
"eslint-plugin-hapi": "4.x", | ||
"sinon": "8.x" | ||
"sinon": "9.x" | ||
}, | ||
@@ -30,0 +30,0 @@ "renovate": { |
@@ -12,3 +12,12 @@ # event-sourcerer-client | ||
```javascript | ||
const Jackrabbit = require('jackrabbit'); | ||
// Default configuration | ||
const Jackrabbit = require('@pager/jackrabbit'); | ||
const { Client } = require('@pager/event-sourcerer-client'); | ||
const exchange = Jackrabbit('amqp://localhost').topic('sourcerer'); | ||
const client = Client.default(exchange); | ||
``` | ||
```javascript | ||
// Manual setup | ||
const Jackrabbit = require('@pager/jackrabbit'); | ||
const EventSourcerer = require('@pager/event-sourcerer-client'); | ||
@@ -18,5 +27,5 @@ const Client = EventSourcerer.Client; | ||
const rabbit = Jackrabbit('amqp://localhost') | ||
const transport = new SingleKeyRabbit(rabbit, { exchangeName: 'pager' }) | ||
const client = new Client(transport) | ||
const exchange = Jackrabbit('amqp://localhost').topic('sourcerer'); | ||
const transport = new SingleKeyRabbit(exchange); | ||
const client = new Client(transport); | ||
``` | ||
@@ -26,8 +35,8 @@ | ||
```javascript | ||
const stream = 'chats' | ||
const streamId = '123456' | ||
const eventType = 'created' | ||
const data = { 'name': 'my chat' } | ||
const stream = 'chats'; | ||
const streamId = '123456'; | ||
const eventType = 'created'; | ||
const data = { 'name': 'my chat' }; | ||
client.publish(stream, streamId, eventType, data) | ||
client.publish(stream, streamId, eventType, data); | ||
``` | ||
@@ -65,8 +74,7 @@ | ||
##### `SingleKeyRabbitTransport(rabbitConnection, options)` | ||
##### `SingleKeyRabbitTransport(publisher, metadata, logger)` | ||
- `rabbit` - Configured connection to rabbit, as the one returned by `@pager/jackrabbit` or a compatible one. | ||
- `options` - settings: | ||
- `exchangeName` - name of the RabbitMQ exchange. Required. | ||
- `exchangeType` - Type of exchange. Optional. Possible values: `topic`, `default`. Defaults to `topic` | ||
- `publisher` (required) - Configured rabbit exchange, as the one returned by `@pager/jackrabbit`'s `.topic()` or `.default()`. Any publisher with a compatible interface will work | ||
- `metadata` - additional published metadata added on to the options param of `publisher.publish` | ||
- `logger` - optional override for default logger | ||
@@ -77,8 +85,6 @@ #### MultiKeyRabbitTransport | ||
##### `MultiKeyRabbitTransport(rabbitConnection, options)` | ||
##### `MultiKeyRabbitTransport(publisher, options)` | ||
- `rabbit` - Configured connection to rabbit, as the one returned by `@pager/jackrabbit` or a compatible one. | ||
- `options` - settings: | ||
- `exchangeName` - name of the RabbitMQ exchange. Required. | ||
- `exchangeType` - Type of exchange. Optional. Possible values: `topic`, `default`. Defaults to `topic` | ||
- `publisher` - Configured rabbit exchange, as the one returned by `@pager/jackrabbit`'s `.topic()` or `.default()`. Any publisher with a compatible interface will work | ||
- `logger` - optional override for default logger | ||
@@ -88,5 +94,1 @@ #### MultiTransport | ||
This transport can be used to publish messages to a RabbitMQ instance, under a single key by stream. The key being `events.{stream}.created`. | ||
##### `SingleKeyRabbitTransport(rabbitConnection, options)` | ||
- `rabbit` - Configured connection to rabbit, as the one returned by `@pager/jackrabbit` or a compatible one. |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7751
101
89
1
+ Addeduuid@7.0.3(transitive)
- Removeduuid@3.4.0(transitive)
Updateduuid@7.x