@palmetto/pubsub 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,13 @@ yarn add @palmetto/pubsub zod
28
28
 
29
29
  ```ts
30
30
  import { z as z4 } from "zod/v4";
31
- import { IdMetaSchema, Publisher, RabbitMqPublisher, RabbitQueueExchangeConfiguration } from "@palmetto/pubsub";
31
+ import {
32
+ IdMetaSchema,
33
+ Publisher,
34
+ RabbitMqPublisher,
35
+ RABBITMQ_TRANSPORT,
36
+ RabbitQueueExchangeConfiguration,
37
+ } from "@palmetto/pubsub";
32
38
 
33
39
  const rabbitMqPublisher = new RabbitMqPublisher(...);
34
40
 
@@ -60,7 +66,15 @@ yarn add @palmetto/pubsub zod
60
66
 
61
67
  ```ts
62
68
  import { z as z4 } from "zod/v4";
63
- import { BaseMessage, IdMetaSchema, MessageResult, Subscriber, RabbitMqSubscriber } from "@palmetto/pubsub";
69
+ import {
70
+ BaseMessage,
71
+ IdMetaSchema,
72
+ MessageResult,
73
+ Subscriber,
74
+ RabbitMqSubscriber,
75
+ RABBITMQ_TRANSPORT,
76
+ RabbitQueueExchangeConfiguration
77
+ } from "@palmetto/pubsub";
64
78
 
65
79
  const rabbitMqSubscriber = new RabbitMqSubscriber(...);
66
80
 
@@ -92,6 +106,14 @@ yarn add @palmetto/pubsub zod
92
106
  await subscriber.startSubscribe(schemaConfig, onMessage);
93
107
  ```
94
108
 
109
+ ### RabbitMQ Usage
110
+
111
+ For specific details about using RabbitMQ see [RabbitMQ README.md](src/rabbitmq/README.md)
112
+
113
+ ### BullMQ Usage
114
+
115
+ For specific details about using BullMQ see [BullMQ README.md](src/bullmq/README.md)
116
+
95
117
  ### Defining schemas
96
118
 
97
119
  All schemas must be defined using `zod/z4`. By convention, all messages should extend the `IdMetaSchema` schema, but it is not strictly required.
package/dist/publisher.js CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Publisher = void 0;
13
13
  const v4_1 = require("zod/v4");
14
14
  const uuid_1 = require("uuid");
15
- const crypto_hash_1 = require("crypto-hash");
15
+ const crypto_1 = require("crypto");
16
16
  const errors_js_1 = require("./errors.js");
17
17
  class Publisher {
18
18
  constructor(logger, providers) {
@@ -43,7 +43,7 @@ class Publisher {
43
43
  init(config) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  yield this.getProvider(config).init(config);
46
- yield this.assertSchema(config);
46
+ this.assertSchema(config);
47
47
  });
48
48
  }
49
49
  publish(config, message) {
@@ -53,7 +53,7 @@ class Publisher {
53
53
  if (!message.id) {
54
54
  message.id = (0, uuid_1.v4)();
55
55
  }
56
- const { schema, schemaId } = yield this.assertSchema(config);
56
+ const { schema, schemaId } = this.assertSchema(config);
57
57
  if (!message.meta) {
58
58
  message.meta = {
59
59
  createdAt: new Date().toISOString(),
@@ -89,19 +89,17 @@ class Publisher {
89
89
  return provider;
90
90
  }
91
91
  assertSchema(config) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const { schema } = config;
94
- let hash = this.hashes.get(schema);
95
- if (!hash) {
96
- const jsonSchema = JSON.stringify(v4_1.z.toJSONSchema(schema), null, 3);
97
- hash = yield (0, crypto_hash_1.sha256)(jsonSchema);
98
- this.hashes.set(schema, hash);
99
- }
100
- return {
101
- schema,
102
- schemaId: hash,
103
- };
104
- });
92
+ const { schema } = config;
93
+ let hash = this.hashes.get(schema);
94
+ if (!hash) {
95
+ const jsonSchema = JSON.stringify(v4_1.z.toJSONSchema(schema), null, 3);
96
+ hash = (0, crypto_1.createHash)("sha256").update(jsonSchema).digest("hex");
97
+ this.hashes.set(schema, hash);
98
+ }
99
+ return {
100
+ schema,
101
+ schemaId: hash,
102
+ };
105
103
  }
106
104
  }
107
105
  exports.Publisher = Publisher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palmetto/pubsub",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "main": "./dist/main.js",
5
5
  "scripts": {
6
6
  "lint": "yarn run -T eslint --fix ./src",
@@ -41,7 +41,6 @@
41
41
  "access": "public"
42
42
  },
43
43
  "dependencies": {
44
- "crypto-hash": "^3.1.0",
45
44
  "uuid": "^11.1.0"
46
45
  },
47
46
  "peerDependencies": {