nestjs-runmq 1.0.0
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 +342 -0
- package/dist/index.cjs +313 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +58 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +284 -0
- package/dist/index.js.map +1 -0
- package/package.json +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# nestjs-runmq
|
|
2
|
+
|
|
3
|
+
NestJS module for [RunMQ](https://github.com/runmq/queue) — decorator-based message processors, an injectable publisher service, and automatic lifecycle management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install nestjs-runmq runmq
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### 1. Register the Module
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// app.module.ts
|
|
19
|
+
import { Module } from '@nestjs/common';
|
|
20
|
+
import { RunMQModule } from 'nestjs-runmq';
|
|
21
|
+
|
|
22
|
+
@Module({
|
|
23
|
+
imports: [
|
|
24
|
+
RunMQModule.forRoot({
|
|
25
|
+
url: 'amqp://localhost:5672',
|
|
26
|
+
reconnectDelay: 3000,
|
|
27
|
+
maxReconnectAttempts: 5,
|
|
28
|
+
management: {
|
|
29
|
+
url: 'http://localhost:15672',
|
|
30
|
+
username: 'guest',
|
|
31
|
+
password: 'guest',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
})
|
|
36
|
+
export class AppModule {}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
RunMQ connects automatically when the app starts and disconnects cleanly on shutdown.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
### 2. Create a Processor
|
|
44
|
+
|
|
45
|
+
Decorate a class with `@Processor()` and mark the handler method with `@ProcessMessage()`:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// email.processor.ts
|
|
49
|
+
import { Injectable } from '@nestjs/common';
|
|
50
|
+
import { Processor, ProcessMessage, RunMQMessageContent } from 'nestjs-runmq';
|
|
51
|
+
|
|
52
|
+
@Processor({
|
|
53
|
+
topic: 'user.created',
|
|
54
|
+
name: 'emailService',
|
|
55
|
+
consumersCount: 2,
|
|
56
|
+
attempts: 3,
|
|
57
|
+
attemptsDelay: 2000,
|
|
58
|
+
})
|
|
59
|
+
@Injectable()
|
|
60
|
+
export class EmailProcessor {
|
|
61
|
+
@ProcessMessage()
|
|
62
|
+
async handle(message: RunMQMessageContent<{ email: string; name: string }>) {
|
|
63
|
+
console.log(`Sending welcome email to ${message.message.email}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Register it as a provider in any module:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
@Module({
|
|
72
|
+
providers: [EmailProcessor],
|
|
73
|
+
})
|
|
74
|
+
export class EmailModule {}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The processor is discovered and registered automatically on startup — no manual wiring needed.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### 3. Publish Messages
|
|
82
|
+
|
|
83
|
+
Inject `RunMQPublisherService` anywhere in your app:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// user.service.ts
|
|
87
|
+
import { Injectable } from '@nestjs/common';
|
|
88
|
+
import { RunMQPublisherService } from 'nestjs-runmq';
|
|
89
|
+
|
|
90
|
+
@Injectable()
|
|
91
|
+
export class UserService {
|
|
92
|
+
constructor(private readonly publisher: RunMQPublisherService) {}
|
|
93
|
+
|
|
94
|
+
async createUser(email: string, name: string) {
|
|
95
|
+
// ... save user
|
|
96
|
+
this.publisher.publish('user.created', { email, name });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Configuration
|
|
104
|
+
|
|
105
|
+
### Static (`forRoot`)
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
RunMQModule.forRoot({
|
|
109
|
+
url: 'amqp://localhost:5672',
|
|
110
|
+
reconnectDelay: 5000, // Optional, default: 5000ms
|
|
111
|
+
maxReconnectAttempts: 5, // Optional, default: 5
|
|
112
|
+
management: { // Optional, enables policy-based TTL
|
|
113
|
+
url: 'http://localhost:15672',
|
|
114
|
+
username: 'guest',
|
|
115
|
+
password: 'guest',
|
|
116
|
+
},
|
|
117
|
+
})
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Async (`forRootAsync`)
|
|
121
|
+
|
|
122
|
+
Load configuration at runtime — e.g., from environment variables via `@nestjs/config`:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// app.module.ts
|
|
126
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
127
|
+
|
|
128
|
+
RunMQModule.forRootAsync({
|
|
129
|
+
imports: [ConfigModule],
|
|
130
|
+
inject: [ConfigService],
|
|
131
|
+
useFactory: (config: ConfigService) => ({
|
|
132
|
+
url: config.get('RABBITMQ_URL'),
|
|
133
|
+
reconnectDelay: config.get('RABBITMQ_RECONNECT_DELAY', 5000),
|
|
134
|
+
maxReconnectAttempts: config.get('RABBITMQ_MAX_RECONNECT_ATTEMPTS', 5),
|
|
135
|
+
management: {
|
|
136
|
+
url: config.get('RABBITMQ_MANAGEMENT_URL'),
|
|
137
|
+
username: config.get('RABBITMQ_MANAGEMENT_USER', 'guest'),
|
|
138
|
+
password: config.get('RABBITMQ_MANAGEMENT_PASS', 'guest'),
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### `useClass`
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { Injectable } from '@nestjs/common';
|
|
148
|
+
import { RunMQOptionsFactory, RunMQModuleOptions } from 'nestjs-runmq';
|
|
149
|
+
|
|
150
|
+
@Injectable()
|
|
151
|
+
export class RabbitMQConfig implements RunMQOptionsFactory {
|
|
152
|
+
createRunMQOptions(): RunMQModuleOptions {
|
|
153
|
+
return {
|
|
154
|
+
url: process.env.RABBITMQ_URL ?? 'amqp://localhost:5672',
|
|
155
|
+
reconnectDelay: 5000,
|
|
156
|
+
maxReconnectAttempts: 5,
|
|
157
|
+
management: {
|
|
158
|
+
url: process.env.RABBITMQ_MANAGEMENT_URL ?? 'http://localhost:15672',
|
|
159
|
+
username: process.env.RABBITMQ_MANAGEMENT_USER ?? 'guest',
|
|
160
|
+
password: process.env.RABBITMQ_MANAGEMENT_PASS ?? 'guest',
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
RunMQModule.forRootAsync({ useClass: RabbitMQConfig })
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### `useExisting`
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
RunMQModule.forRootAsync({ useExisting: RabbitMQConfig })
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Decorators
|
|
178
|
+
|
|
179
|
+
### `@Processor(options)`
|
|
180
|
+
|
|
181
|
+
Class-level decorator. Marks a class as a RunMQ message processor.
|
|
182
|
+
|
|
183
|
+
| Option | Type | Required | Default | Description |
|
|
184
|
+
|--------|------|----------|---------|-------------|
|
|
185
|
+
| `topic` | `string` | Yes | — | Topic to subscribe to |
|
|
186
|
+
| `name` | `string` | Yes | — | Unique processor name (creates an isolated queue) |
|
|
187
|
+
| `consumersCount` | `number` | No | `1` | Concurrent consumers |
|
|
188
|
+
| `attempts` | `number` | No | `1` | Max retry attempts |
|
|
189
|
+
| `attemptsDelay` | `number` | No | `1000` | Milliseconds between retries |
|
|
190
|
+
| `messageSchema` | `MessageSchema` | No | — | Optional JSON schema validation |
|
|
191
|
+
| `usePoliciesForDelay` | `boolean` | No | `false` | Use RabbitMQ policies for delay queues (recommended) |
|
|
192
|
+
|
|
193
|
+
### `@ProcessMessage()`
|
|
194
|
+
|
|
195
|
+
Method-level decorator. Marks which method handles incoming messages. Exactly **one** method per `@Processor` class must be decorated.
|
|
196
|
+
|
|
197
|
+
**Method signature**: `(message: RunMQMessageContent<T>) => Promise<void>`
|
|
198
|
+
|
|
199
|
+
### `@InjectRunMQ()`
|
|
200
|
+
|
|
201
|
+
Parameter decorator. Injects the raw `RunMQ` instance for advanced use cases:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { Injectable } from '@nestjs/common';
|
|
205
|
+
import { InjectRunMQ } from 'nestjs-runmq';
|
|
206
|
+
import { RunMQ } from 'runmq';
|
|
207
|
+
|
|
208
|
+
@Injectable()
|
|
209
|
+
export class HealthService {
|
|
210
|
+
constructor(@InjectRunMQ() private readonly runmq: RunMQ) {}
|
|
211
|
+
|
|
212
|
+
check() {
|
|
213
|
+
return { rabbitmq: this.runmq.isActive() };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Injectable Services
|
|
221
|
+
|
|
222
|
+
### `RunMQPublisherService`
|
|
223
|
+
|
|
224
|
+
| Method | Signature | Description |
|
|
225
|
+
|--------|-----------|-------------|
|
|
226
|
+
| `publish` | `(topic: string, message: Record<string, any>, correlationId?: string) => void` | Publishes a message to the given topic |
|
|
227
|
+
|
|
228
|
+
Throws `'RunMQ is not connected'` if called before the connection is established.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Error Handling
|
|
233
|
+
|
|
234
|
+
| Scenario | Behavior |
|
|
235
|
+
|----------|----------|
|
|
236
|
+
| RabbitMQ unreachable at startup | Logged via NestJS Logger, error is re-thrown |
|
|
237
|
+
| `publish()` before connection | Throws `Error('RunMQ is not connected')` |
|
|
238
|
+
| Duplicate `@Processor` name | Throws at startup: `Duplicate processor name: {name}` |
|
|
239
|
+
| No `@ProcessMessage` in a `@Processor` class | Throws at startup: `No @ProcessMessage handler found in {ClassName}` |
|
|
240
|
+
| Multiple `@ProcessMessage` in one class | Throws at startup: `Multiple @ProcessMessage handlers in {ClassName}` |
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Re-exported Types
|
|
245
|
+
|
|
246
|
+
The following types from `runmq` are re-exported for convenience:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import {
|
|
250
|
+
RunMQMessageContent,
|
|
251
|
+
RunMQMessageMetaContent,
|
|
252
|
+
RunMQConnectionConfig,
|
|
253
|
+
RunMQProcessorConfiguration,
|
|
254
|
+
MessageSchema,
|
|
255
|
+
SchemaType,
|
|
256
|
+
SchemaFailureStrategy,
|
|
257
|
+
RabbitMQManagementConfig,
|
|
258
|
+
RunMQLogger,
|
|
259
|
+
RunMQ,
|
|
260
|
+
} from 'nestjs-runmq';
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Full Example
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// app.module.ts
|
|
269
|
+
import { Module } from '@nestjs/common';
|
|
270
|
+
import { RunMQModule } from 'nestjs-runmq';
|
|
271
|
+
import { EmailModule } from './email/email.module';
|
|
272
|
+
import { UserModule } from './user/user.module';
|
|
273
|
+
|
|
274
|
+
@Module({
|
|
275
|
+
imports: [
|
|
276
|
+
RunMQModule.forRoot({
|
|
277
|
+
url: 'amqp://localhost:5672',
|
|
278
|
+
reconnectDelay: 5000,
|
|
279
|
+
maxReconnectAttempts: 5,
|
|
280
|
+
management: {
|
|
281
|
+
url: 'http://localhost:15672',
|
|
282
|
+
username: 'guest',
|
|
283
|
+
password: 'guest',
|
|
284
|
+
},
|
|
285
|
+
}),
|
|
286
|
+
EmailModule,
|
|
287
|
+
UserModule,
|
|
288
|
+
],
|
|
289
|
+
})
|
|
290
|
+
export class AppModule {}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
// email/email.processor.ts
|
|
295
|
+
import { Injectable } from '@nestjs/common';
|
|
296
|
+
import { Processor, ProcessMessage, RunMQMessageContent } from 'nestjs-runmq';
|
|
297
|
+
|
|
298
|
+
@Processor({ topic: 'user.created', name: 'emailService', consumersCount: 2, attempts: 3 })
|
|
299
|
+
@Injectable()
|
|
300
|
+
export class EmailProcessor {
|
|
301
|
+
@ProcessMessage()
|
|
302
|
+
async handle(message: RunMQMessageContent<{ email: string; name: string }>) {
|
|
303
|
+
console.log(`Sending welcome email to ${message.message.email}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// email/email.module.ts
|
|
310
|
+
import { Module } from '@nestjs/common';
|
|
311
|
+
import { EmailProcessor } from './email.processor';
|
|
312
|
+
|
|
313
|
+
@Module({ providers: [EmailProcessor] })
|
|
314
|
+
export class EmailModule {}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// user/user.service.ts
|
|
319
|
+
import { Injectable } from '@nestjs/common';
|
|
320
|
+
import { RunMQPublisherService } from 'nestjs-runmq';
|
|
321
|
+
|
|
322
|
+
@Injectable()
|
|
323
|
+
export class UserService {
|
|
324
|
+
constructor(private readonly publisher: RunMQPublisherService) {}
|
|
325
|
+
|
|
326
|
+
async createUser(email: string, name: string) {
|
|
327
|
+
this.publisher.publish('user.created', { email, name });
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Dashboard
|
|
335
|
+
|
|
336
|
+
Monitor your queues, processors, and messages in real time with [RunMQ Pulse](https://github.com/runmq/pulse).
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## License
|
|
341
|
+
|
|
342
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
49
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
50
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
51
|
+
if (decorator = decorators[i])
|
|
52
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
53
|
+
if (kind && result) __defProp(target, key, result);
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
57
|
+
|
|
58
|
+
// src/index.ts
|
|
59
|
+
var index_exports = {};
|
|
60
|
+
__export(index_exports, {
|
|
61
|
+
InjectRunMQ: () => InjectRunMQ,
|
|
62
|
+
ProcessMessage: () => ProcessMessage,
|
|
63
|
+
Processor: () => Processor,
|
|
64
|
+
RunMQ: () => import_runmq5.RunMQ,
|
|
65
|
+
RunMQModule: () => RunMQModule,
|
|
66
|
+
RunMQPublisherService: () => RunMQPublisherService,
|
|
67
|
+
RunMQService: () => RunMQService
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(index_exports);
|
|
70
|
+
|
|
71
|
+
// src/runmq.module.ts
|
|
72
|
+
var import_common5 = require("@nestjs/common");
|
|
73
|
+
var import_core2 = require("@nestjs/core");
|
|
74
|
+
var import_runmq = require("runmq");
|
|
75
|
+
|
|
76
|
+
// src/constants.ts
|
|
77
|
+
var RUNMQ_INSTANCE = /* @__PURE__ */ Symbol("RUNMQ_INSTANCE");
|
|
78
|
+
var RUNMQ_MODULE_OPTIONS = /* @__PURE__ */ Symbol("RUNMQ_MODULE_OPTIONS");
|
|
79
|
+
var RUNMQ_PROCESSOR_METADATA = "RUNMQ_PROCESSOR";
|
|
80
|
+
var RUNMQ_HANDLER_METADATA = "RUNMQ_HANDLER";
|
|
81
|
+
|
|
82
|
+
// src/runmq.service.ts
|
|
83
|
+
var import_common = require("@nestjs/common");
|
|
84
|
+
var RunMQService = class {
|
|
85
|
+
constructor(_instance) {
|
|
86
|
+
this._instance = _instance;
|
|
87
|
+
this.logger = new import_common.Logger(RunMQService.name);
|
|
88
|
+
}
|
|
89
|
+
async onModuleDestroy() {
|
|
90
|
+
try {
|
|
91
|
+
await this._instance.disconnect();
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.logger.error(
|
|
94
|
+
`RunMQ disconnect error: ${error instanceof Error ? error.message : String(error)}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
get instance() {
|
|
99
|
+
return this._instance;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
RunMQService = __decorateClass([
|
|
103
|
+
(0, import_common.Injectable)(),
|
|
104
|
+
__decorateParam(0, (0, import_common.Inject)(RUNMQ_INSTANCE))
|
|
105
|
+
], RunMQService);
|
|
106
|
+
|
|
107
|
+
// src/runmq-explorer.service.ts
|
|
108
|
+
var import_common2 = require("@nestjs/common");
|
|
109
|
+
var import_core = require("@nestjs/core");
|
|
110
|
+
var RunMQExplorerService = class {
|
|
111
|
+
constructor(discoveryService, runmq) {
|
|
112
|
+
this.discoveryService = discoveryService;
|
|
113
|
+
this.runmq = runmq;
|
|
114
|
+
}
|
|
115
|
+
async onModuleInit() {
|
|
116
|
+
var _b;
|
|
117
|
+
const providers = this.discoveryService.getProviders();
|
|
118
|
+
const registeredNames = /* @__PURE__ */ new Set();
|
|
119
|
+
for (const wrapper of providers) {
|
|
120
|
+
const { instance, metatype } = wrapper;
|
|
121
|
+
if (!instance || !metatype) continue;
|
|
122
|
+
const processorOptions = Reflect.getMetadata(RUNMQ_PROCESSOR_METADATA, metatype);
|
|
123
|
+
if (!processorOptions) continue;
|
|
124
|
+
const className = metatype.name;
|
|
125
|
+
if (registeredNames.has(processorOptions.name)) {
|
|
126
|
+
throw new Error(`Duplicate processor name: ${processorOptions.name}`);
|
|
127
|
+
}
|
|
128
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
129
|
+
const methodNames = Object.getOwnPropertyNames(prototype).filter(
|
|
130
|
+
(key) => key !== "constructor"
|
|
131
|
+
);
|
|
132
|
+
const handlerMethods = methodNames.filter(
|
|
133
|
+
(key) => Reflect.getMetadata(RUNMQ_HANDLER_METADATA, prototype, key)
|
|
134
|
+
);
|
|
135
|
+
if (handlerMethods.length === 0) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`No @ProcessMessage handler found in ${className}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (handlerMethods.length > 1) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Multiple @ProcessMessage handlers in ${className}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
registeredNames.add(processorOptions.name);
|
|
146
|
+
const handlerName = handlerMethods[0];
|
|
147
|
+
const handler = instance[handlerName].bind(instance);
|
|
148
|
+
const _a = processorOptions, { topic } = _a, config = __objRest(_a, ["topic"]);
|
|
149
|
+
await this.runmq.process(
|
|
150
|
+
topic,
|
|
151
|
+
__spreadProps(__spreadValues({}, config), { consumersCount: (_b = config.consumersCount) != null ? _b : 1 }),
|
|
152
|
+
handler
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
RunMQExplorerService = __decorateClass([
|
|
158
|
+
(0, import_common2.Injectable)(),
|
|
159
|
+
__decorateParam(0, (0, import_common2.Inject)(import_core.DiscoveryService)),
|
|
160
|
+
__decorateParam(1, (0, import_common2.Inject)(RUNMQ_INSTANCE))
|
|
161
|
+
], RunMQExplorerService);
|
|
162
|
+
|
|
163
|
+
// src/runmq-publisher.service.ts
|
|
164
|
+
var import_common3 = require("@nestjs/common");
|
|
165
|
+
var RunMQPublisherService = class {
|
|
166
|
+
constructor(runmq) {
|
|
167
|
+
this.runmq = runmq;
|
|
168
|
+
}
|
|
169
|
+
publish(topic, message, correlationId) {
|
|
170
|
+
if (!this.runmq.isActive()) {
|
|
171
|
+
throw new Error("RunMQ is not connected");
|
|
172
|
+
}
|
|
173
|
+
this.runmq.publish(topic, message, correlationId);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
RunMQPublisherService = __decorateClass([
|
|
177
|
+
(0, import_common3.Injectable)(),
|
|
178
|
+
__decorateParam(0, (0, import_common3.Inject)(RUNMQ_INSTANCE))
|
|
179
|
+
], RunMQPublisherService);
|
|
180
|
+
|
|
181
|
+
// src/logger-adapter.ts
|
|
182
|
+
var import_common4 = require("@nestjs/common");
|
|
183
|
+
var NestJSRunMQLogger = class {
|
|
184
|
+
constructor() {
|
|
185
|
+
this.logger = new import_common4.Logger("RunMQ");
|
|
186
|
+
}
|
|
187
|
+
log(message, ...optionalParams) {
|
|
188
|
+
this.logger.log(message, ...optionalParams);
|
|
189
|
+
}
|
|
190
|
+
error(message, ...optionalParams) {
|
|
191
|
+
this.logger.error(message, ...optionalParams);
|
|
192
|
+
}
|
|
193
|
+
warn(message, ...optionalParams) {
|
|
194
|
+
this.logger.warn(message, ...optionalParams);
|
|
195
|
+
}
|
|
196
|
+
info(message, ...optionalParams) {
|
|
197
|
+
this.logger.log(message, ...optionalParams);
|
|
198
|
+
}
|
|
199
|
+
debug(message, ...optionalParams) {
|
|
200
|
+
this.logger.debug(message, ...optionalParams);
|
|
201
|
+
}
|
|
202
|
+
verbose(message, ...optionalParams) {
|
|
203
|
+
this.logger.verbose(message, ...optionalParams);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/runmq.module.ts
|
|
208
|
+
var RunMQModule = class {
|
|
209
|
+
static forRoot(options) {
|
|
210
|
+
return RunMQModule.buildDynamicModule(
|
|
211
|
+
[{ provide: RUNMQ_MODULE_OPTIONS, useValue: options }]
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
static forRootAsync(options) {
|
|
215
|
+
return RunMQModule.buildDynamicModule(
|
|
216
|
+
RunMQModule.createAsyncProviders(options),
|
|
217
|
+
options.imports
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
static buildDynamicModule(optionsProviders, extraImports = []) {
|
|
221
|
+
return {
|
|
222
|
+
global: true,
|
|
223
|
+
module: RunMQModule,
|
|
224
|
+
imports: [import_core2.DiscoveryModule, ...extraImports],
|
|
225
|
+
providers: [
|
|
226
|
+
...optionsProviders,
|
|
227
|
+
{
|
|
228
|
+
provide: RUNMQ_INSTANCE,
|
|
229
|
+
useFactory: async (options) => import_runmq.RunMQ.start(options, new NestJSRunMQLogger()),
|
|
230
|
+
inject: [RUNMQ_MODULE_OPTIONS]
|
|
231
|
+
},
|
|
232
|
+
RunMQService,
|
|
233
|
+
RunMQExplorerService,
|
|
234
|
+
RunMQPublisherService
|
|
235
|
+
],
|
|
236
|
+
exports: [RunMQService, RUNMQ_INSTANCE, RunMQPublisherService]
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
static createAsyncProviders(options) {
|
|
240
|
+
var _a;
|
|
241
|
+
if (options.useFactory) {
|
|
242
|
+
return [
|
|
243
|
+
{
|
|
244
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
245
|
+
useFactory: options.useFactory,
|
|
246
|
+
inject: (_a = options.inject) != null ? _a : []
|
|
247
|
+
}
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
if (options.useClass) {
|
|
251
|
+
return [
|
|
252
|
+
{
|
|
253
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
254
|
+
useFactory: async (factory) => factory.createRunMQOptions(),
|
|
255
|
+
inject: [options.useClass]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
provide: options.useClass,
|
|
259
|
+
useClass: options.useClass
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
if (options.useExisting) {
|
|
264
|
+
return [
|
|
265
|
+
{
|
|
266
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
267
|
+
useFactory: async (factory) => factory.createRunMQOptions(),
|
|
268
|
+
inject: [options.useExisting]
|
|
269
|
+
}
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
throw new Error(
|
|
273
|
+
"RunMQModule.forRootAsync() requires useFactory, useClass, or useExisting"
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
RunMQModule = __decorateClass([
|
|
278
|
+
(0, import_common5.Module)({})
|
|
279
|
+
], RunMQModule);
|
|
280
|
+
|
|
281
|
+
// src/decorators/processor.decorator.ts
|
|
282
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
283
|
+
function Processor(options) {
|
|
284
|
+
return (target) => {
|
|
285
|
+
Reflect.defineMetadata(RUNMQ_PROCESSOR_METADATA, options, target);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/decorators/process-message.decorator.ts
|
|
290
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
291
|
+
function ProcessMessage() {
|
|
292
|
+
return (target, propertyKey) => {
|
|
293
|
+
Reflect.defineMetadata(RUNMQ_HANDLER_METADATA, propertyKey, target, propertyKey);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/decorators/inject-runmq.decorator.ts
|
|
298
|
+
var import_common6 = require("@nestjs/common");
|
|
299
|
+
var InjectRunMQ = () => (0, import_common6.Inject)(RUNMQ_INSTANCE);
|
|
300
|
+
|
|
301
|
+
// src/index.ts
|
|
302
|
+
var import_runmq5 = require("runmq");
|
|
303
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
304
|
+
0 && (module.exports = {
|
|
305
|
+
InjectRunMQ,
|
|
306
|
+
ProcessMessage,
|
|
307
|
+
Processor,
|
|
308
|
+
RunMQ,
|
|
309
|
+
RunMQModule,
|
|
310
|
+
RunMQPublisherService,
|
|
311
|
+
RunMQService
|
|
312
|
+
});
|
|
313
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/runmq.module.ts","../src/constants.ts","../src/runmq.service.ts","../src/runmq-explorer.service.ts","../src/runmq-publisher.service.ts","../src/logger-adapter.ts","../src/decorators/processor.decorator.ts","../src/decorators/process-message.decorator.ts","../src/decorators/inject-runmq.decorator.ts"],"sourcesContent":["export { RunMQModule } from './runmq.module';\n\nexport { RunMQService } from './runmq.service';\nexport { RunMQPublisherService } from './runmq-publisher.service';\n\nexport { Processor } from './decorators/processor.decorator';\nexport { ProcessMessage } from './decorators/process-message.decorator';\nexport { InjectRunMQ } from './decorators/inject-runmq.decorator';\n\nexport type { RunMQModuleOptions, RunMQOptionsFactory } from './interfaces/runmq-module-options.interface';\nexport type { RunMQAsyncModuleOptions } from './interfaces/runmq-async-options.interface';\nexport type { ProcessorDecoratorOptions } from './decorators/processor.decorator';\n\nexport type {\n RunMQMessageContent,\n RunMQMessageMetaContent,\n RunMQConnectionConfig,\n RunMQProcessorConfiguration,\n MessageSchema,\n SchemaType,\n SchemaFailureStrategy,\n RabbitMQManagementConfig,\n RunMQLogger,\n RunMQQueueMetadata,\n} from 'runmq';\nexport { RunMQ } from 'runmq';\n","import { DynamicModule, Module, Provider } from '@nestjs/common';\nimport { DiscoveryModule } from '@nestjs/core';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE, RUNMQ_MODULE_OPTIONS } from './constants';\nimport { RunMQModuleOptions, RunMQOptionsFactory } from './interfaces/runmq-module-options.interface';\nimport { RunMQAsyncModuleOptions } from './interfaces/runmq-async-options.interface';\nimport { RunMQService } from './runmq.service';\nimport { RunMQExplorerService } from './runmq-explorer.service';\nimport { RunMQPublisherService } from './runmq-publisher.service';\nimport { NestJSRunMQLogger } from './logger-adapter';\n\n@Module({})\nexport class RunMQModule {\n static forRoot(options: RunMQModuleOptions): DynamicModule {\n return RunMQModule.buildDynamicModule(\n [{ provide: RUNMQ_MODULE_OPTIONS, useValue: options }],\n );\n }\n\n static forRootAsync(options: RunMQAsyncModuleOptions): DynamicModule {\n return RunMQModule.buildDynamicModule(\n RunMQModule.createAsyncProviders(options),\n options.imports,\n );\n }\n\n private static buildDynamicModule(\n optionsProviders: Provider[],\n extraImports: any[] = [],\n ): DynamicModule {\n return {\n global: true,\n module: RunMQModule,\n imports: [DiscoveryModule, ...extraImports],\n providers: [\n ...optionsProviders,\n {\n provide: RUNMQ_INSTANCE,\n useFactory: async (options: RunMQModuleOptions) =>\n RunMQ.start(options, new NestJSRunMQLogger()),\n inject: [RUNMQ_MODULE_OPTIONS],\n },\n RunMQService,\n RunMQExplorerService,\n RunMQPublisherService,\n ],\n exports: [RunMQService, RUNMQ_INSTANCE, RunMQPublisherService],\n };\n }\n\n private static createAsyncProviders(options: RunMQAsyncModuleOptions): Provider[] {\n if (options.useFactory) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: options.useFactory,\n inject: options.inject ?? [],\n },\n ];\n }\n\n if (options.useClass) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: async (factory: RunMQOptionsFactory) =>\n factory.createRunMQOptions(),\n inject: [options.useClass],\n },\n {\n provide: options.useClass,\n useClass: options.useClass,\n },\n ];\n }\n\n if (options.useExisting) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: async (factory: RunMQOptionsFactory) =>\n factory.createRunMQOptions(),\n inject: [options.useExisting],\n },\n ];\n }\n\n throw new Error(\n 'RunMQModule.forRootAsync() requires useFactory, useClass, or useExisting',\n );\n }\n}\n","export const RUNMQ_INSTANCE = Symbol('RUNMQ_INSTANCE');\nexport const RUNMQ_MODULE_OPTIONS = Symbol('RUNMQ_MODULE_OPTIONS');\n\nexport const RUNMQ_PROCESSOR_METADATA = 'RUNMQ_PROCESSOR';\nexport const RUNMQ_HANDLER_METADATA = 'RUNMQ_HANDLER';\n","import { Injectable, Inject, OnModuleDestroy, Logger } from '@nestjs/common';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE } from './constants';\n\n@Injectable()\nexport class RunMQService implements OnModuleDestroy {\n private readonly logger = new Logger(RunMQService.name);\n\n constructor(\n @Inject(RUNMQ_INSTANCE) private readonly _instance: RunMQ,\n ) {}\n\n async onModuleDestroy(): Promise<void> {\n try {\n await this._instance.disconnect();\n } catch (error) {\n this.logger.error(\n `RunMQ disconnect error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n get instance(): RunMQ {\n return this._instance;\n }\n}\n","import { Injectable, Inject, OnModuleInit } from '@nestjs/common';\nimport { DiscoveryService } from '@nestjs/core';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_PROCESSOR_METADATA, RUNMQ_HANDLER_METADATA, RUNMQ_INSTANCE } from './constants';\nimport type { ProcessorDecoratorOptions } from './decorators/processor.decorator';\n\n@Injectable()\nexport class RunMQExplorerService implements OnModuleInit {\n constructor(\n @Inject(DiscoveryService) private readonly discoveryService: DiscoveryService,\n @Inject(RUNMQ_INSTANCE) private readonly runmq: RunMQ,\n ) {}\n\n async onModuleInit(): Promise<void> {\n const providers = this.discoveryService.getProviders();\n const registeredNames = new Set<string>();\n\n for (const wrapper of providers) {\n const { instance, metatype } = wrapper;\n\n if (!instance || !metatype) continue;\n\n const processorOptions: ProcessorDecoratorOptions | undefined =\n Reflect.getMetadata(RUNMQ_PROCESSOR_METADATA, metatype);\n\n if (!processorOptions) continue;\n\n const className = metatype.name;\n\n // Check for duplicate processor names\n if (registeredNames.has(processorOptions.name)) {\n throw new Error(`Duplicate processor name: ${processorOptions.name}`);\n }\n\n // Find method decorated with @ProcessMessage()\n const prototype = Object.getPrototypeOf(instance);\n const methodNames = Object.getOwnPropertyNames(prototype).filter(\n (key) => key !== 'constructor',\n );\n\n const handlerMethods = methodNames.filter((key) =>\n Reflect.getMetadata(RUNMQ_HANDLER_METADATA, prototype, key),\n );\n\n if (handlerMethods.length === 0) {\n throw new Error(\n `No @ProcessMessage handler found in ${className}`,\n );\n }\n\n if (handlerMethods.length > 1) {\n throw new Error(\n `Multiple @ProcessMessage handlers in ${className}`,\n );\n }\n\n registeredNames.add(processorOptions.name);\n\n const handlerName = handlerMethods[0];\n const handler = instance[handlerName].bind(instance);\n\n const { topic, ...config } = processorOptions;\n await this.runmq.process(\n topic,\n { ...config, consumersCount: config.consumersCount ?? 1 },\n handler,\n );\n }\n }\n}\n","import { Injectable, Inject } from '@nestjs/common';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE } from './constants';\n\n@Injectable()\nexport class RunMQPublisherService {\n constructor(\n @Inject(RUNMQ_INSTANCE) private readonly runmq: RunMQ,\n ) {}\n\n publish(topic: string, message: Record<string, any>, correlationId?: string): void {\n if (!this.runmq.isActive()) {\n throw new Error('RunMQ is not connected');\n }\n this.runmq.publish(topic, message, correlationId);\n }\n}\n","import { Logger } from '@nestjs/common';\nimport type { RunMQLogger } from 'runmq';\n\nexport class NestJSRunMQLogger implements RunMQLogger {\n private readonly logger = new Logger('RunMQ');\n\n log(message: string, ...optionalParams: any[]): void {\n this.logger.log(message, ...optionalParams);\n }\n\n error(message: string, ...optionalParams: any[]): void {\n this.logger.error(message, ...optionalParams);\n }\n\n warn(message: string, ...optionalParams: any[]): void {\n this.logger.warn(message, ...optionalParams);\n }\n\n info(message: string, ...optionalParams: any[]): void {\n this.logger.log(message, ...optionalParams);\n }\n\n debug(message: string, ...optionalParams: any[]): void {\n this.logger.debug(message, ...optionalParams);\n }\n\n verbose(message: string, ...optionalParams: any[]): void {\n this.logger.verbose(message, ...optionalParams);\n }\n}\n","import 'reflect-metadata';\nimport { RUNMQ_PROCESSOR_METADATA } from '../constants';\nimport type { MessageSchema } from 'runmq';\n\nexport interface ProcessorDecoratorOptions {\n topic: string;\n name: string;\n consumersCount?: number;\n attempts?: number;\n attemptsDelay?: number;\n messageSchema?: MessageSchema;\n usePoliciesForDelay?: boolean;\n}\n\nexport function Processor(options: ProcessorDecoratorOptions): ClassDecorator {\n return (target) => {\n Reflect.defineMetadata(RUNMQ_PROCESSOR_METADATA, options, target);\n };\n}\n","import 'reflect-metadata';\nimport { RUNMQ_HANDLER_METADATA } from '../constants';\n\nexport function ProcessMessage(): MethodDecorator {\n return (target, propertyKey) => {\n Reflect.defineMetadata(RUNMQ_HANDLER_METADATA, propertyKey, target, propertyKey);\n };\n}\n","import { Inject } from '@nestjs/common';\nimport { RUNMQ_INSTANCE } from '../constants';\n\nexport const InjectRunMQ = (): ParameterDecorator => Inject(RUNMQ_INSTANCE);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAgD;AAChD,IAAAC,eAAgC;AAChC,mBAAsB;;;ACFf,IAAM,iBAAiB,uBAAO,gBAAgB;AAC9C,IAAM,uBAAuB,uBAAO,sBAAsB;AAE1D,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;;;ACJtC,oBAA4D;AAKrD,IAAM,eAAN,MAA8C;AAAA,EAGnD,YAC2C,WACzC;AADyC;AAH3C,SAAiB,SAAS,IAAI,qBAAO,aAAa,IAAI;AAAA,EAInD;AAAA,EAEH,MAAM,kBAAiC;AACrC,QAAI;AACF,YAAM,KAAK,UAAU,WAAW;AAAA,IAClC,SAAS,OAAO;AACd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AQ;AAAA,QAC3B;AAAA,QACA;AAAA,UACE,SAAS,QAAQ;AAAA,UACjB,UAAU,QAAQ;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,QAAQ,aAAa;AACvB,aAAO;AAAA,QACL;AAAA,UACE,SAAS;AAAA,UACT,YAAY,OAAO,YACjB,QAAQ,mBAAmB;AAAA,UAC7B,QAAQ,CAAC,QAAQ,WAAW;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AA/Ea,cAAN;AAAA,MADN,uBAAO,CAAC,CAAC;AAAA,GACG;;;AMZb,8BAAO;AAcA,SAAS,UAAU,SAAoD;AAC5E,SAAO,CAAC,WAAW;AACjB,YAAQ,eAAe,0BAA0B,SAAS,MAAM;AAAA,EAClE;AACF;;;AClBA,IAAAC,2BAAO;AAGA,SAAS,iBAAkC;AAChD,SAAO,CAAC,QAAQ,gBAAgB;AAC9B,YAAQ,eAAe,wBAAwB,aAAa,QAAQ,WAAW;AAAA,EACjF;AACF;;;ACPA,IAAAC,iBAAuB;AAGhB,IAAM,cAAc,UAA0B,uBAAO,cAAc;;;ATsB1E,IAAAC,gBAAsB;","names":["import_common","import_core","import_common","import_common","import_common","import_reflect_metadata","import_common","import_runmq"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { RabbitMQManagementConfig, RunMQ, MessageSchema } from 'runmq';
|
|
3
|
+
export { MessageSchema, RabbitMQManagementConfig, RunMQ, RunMQConnectionConfig, RunMQLogger, RunMQMessageContent, RunMQMessageMetaContent, RunMQProcessorConfiguration, RunMQQueueMetadata, SchemaFailureStrategy, SchemaType } from 'runmq';
|
|
4
|
+
|
|
5
|
+
interface RunMQModuleOptions {
|
|
6
|
+
url: string;
|
|
7
|
+
reconnectDelay?: number;
|
|
8
|
+
maxReconnectAttempts?: number;
|
|
9
|
+
management?: RabbitMQManagementConfig;
|
|
10
|
+
}
|
|
11
|
+
interface RunMQOptionsFactory {
|
|
12
|
+
createRunMQOptions(): RunMQModuleOptions | Promise<RunMQModuleOptions>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface RunMQAsyncModuleOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
16
|
+
useFactory?: (...args: any[]) => RunMQModuleOptions | Promise<RunMQModuleOptions>;
|
|
17
|
+
inject?: any[];
|
|
18
|
+
useClass?: Type<RunMQOptionsFactory>;
|
|
19
|
+
useExisting?: Type<RunMQOptionsFactory>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class RunMQModule {
|
|
23
|
+
static forRoot(options: RunMQModuleOptions): DynamicModule;
|
|
24
|
+
static forRootAsync(options: RunMQAsyncModuleOptions): DynamicModule;
|
|
25
|
+
private static buildDynamicModule;
|
|
26
|
+
private static createAsyncProviders;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class RunMQService implements OnModuleDestroy {
|
|
30
|
+
private readonly _instance;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
constructor(_instance: RunMQ);
|
|
33
|
+
onModuleDestroy(): Promise<void>;
|
|
34
|
+
get instance(): RunMQ;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class RunMQPublisherService {
|
|
38
|
+
private readonly runmq;
|
|
39
|
+
constructor(runmq: RunMQ);
|
|
40
|
+
publish(topic: string, message: Record<string, any>, correlationId?: string): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface ProcessorDecoratorOptions {
|
|
44
|
+
topic: string;
|
|
45
|
+
name: string;
|
|
46
|
+
consumersCount?: number;
|
|
47
|
+
attempts?: number;
|
|
48
|
+
attemptsDelay?: number;
|
|
49
|
+
messageSchema?: MessageSchema;
|
|
50
|
+
usePoliciesForDelay?: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare function Processor(options: ProcessorDecoratorOptions): ClassDecorator;
|
|
53
|
+
|
|
54
|
+
declare function ProcessMessage(): MethodDecorator;
|
|
55
|
+
|
|
56
|
+
declare const InjectRunMQ: () => ParameterDecorator;
|
|
57
|
+
|
|
58
|
+
export { InjectRunMQ, ProcessMessage, Processor, type ProcessorDecoratorOptions, type RunMQAsyncModuleOptions, RunMQModule, type RunMQModuleOptions, type RunMQOptionsFactory, RunMQPublisherService, RunMQService };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ModuleMetadata, Type, DynamicModule, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { RabbitMQManagementConfig, RunMQ, MessageSchema } from 'runmq';
|
|
3
|
+
export { MessageSchema, RabbitMQManagementConfig, RunMQ, RunMQConnectionConfig, RunMQLogger, RunMQMessageContent, RunMQMessageMetaContent, RunMQProcessorConfiguration, RunMQQueueMetadata, SchemaFailureStrategy, SchemaType } from 'runmq';
|
|
4
|
+
|
|
5
|
+
interface RunMQModuleOptions {
|
|
6
|
+
url: string;
|
|
7
|
+
reconnectDelay?: number;
|
|
8
|
+
maxReconnectAttempts?: number;
|
|
9
|
+
management?: RabbitMQManagementConfig;
|
|
10
|
+
}
|
|
11
|
+
interface RunMQOptionsFactory {
|
|
12
|
+
createRunMQOptions(): RunMQModuleOptions | Promise<RunMQModuleOptions>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface RunMQAsyncModuleOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
16
|
+
useFactory?: (...args: any[]) => RunMQModuleOptions | Promise<RunMQModuleOptions>;
|
|
17
|
+
inject?: any[];
|
|
18
|
+
useClass?: Type<RunMQOptionsFactory>;
|
|
19
|
+
useExisting?: Type<RunMQOptionsFactory>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class RunMQModule {
|
|
23
|
+
static forRoot(options: RunMQModuleOptions): DynamicModule;
|
|
24
|
+
static forRootAsync(options: RunMQAsyncModuleOptions): DynamicModule;
|
|
25
|
+
private static buildDynamicModule;
|
|
26
|
+
private static createAsyncProviders;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class RunMQService implements OnModuleDestroy {
|
|
30
|
+
private readonly _instance;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
constructor(_instance: RunMQ);
|
|
33
|
+
onModuleDestroy(): Promise<void>;
|
|
34
|
+
get instance(): RunMQ;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class RunMQPublisherService {
|
|
38
|
+
private readonly runmq;
|
|
39
|
+
constructor(runmq: RunMQ);
|
|
40
|
+
publish(topic: string, message: Record<string, any>, correlationId?: string): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface ProcessorDecoratorOptions {
|
|
44
|
+
topic: string;
|
|
45
|
+
name: string;
|
|
46
|
+
consumersCount?: number;
|
|
47
|
+
attempts?: number;
|
|
48
|
+
attemptsDelay?: number;
|
|
49
|
+
messageSchema?: MessageSchema;
|
|
50
|
+
usePoliciesForDelay?: boolean;
|
|
51
|
+
}
|
|
52
|
+
declare function Processor(options: ProcessorDecoratorOptions): ClassDecorator;
|
|
53
|
+
|
|
54
|
+
declare function ProcessMessage(): MethodDecorator;
|
|
55
|
+
|
|
56
|
+
declare const InjectRunMQ: () => ParameterDecorator;
|
|
57
|
+
|
|
58
|
+
export { InjectRunMQ, ProcessMessage, Processor, type ProcessorDecoratorOptions, type RunMQAsyncModuleOptions, RunMQModule, type RunMQModuleOptions, type RunMQOptionsFactory, RunMQPublisherService, RunMQService };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
34
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
35
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
36
|
+
if (decorator = decorators[i])
|
|
37
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
38
|
+
if (kind && result) __defProp(target, key, result);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
42
|
+
|
|
43
|
+
// src/runmq.module.ts
|
|
44
|
+
import { Module } from "@nestjs/common";
|
|
45
|
+
import { DiscoveryModule } from "@nestjs/core";
|
|
46
|
+
import { RunMQ } from "runmq";
|
|
47
|
+
|
|
48
|
+
// src/constants.ts
|
|
49
|
+
var RUNMQ_INSTANCE = /* @__PURE__ */ Symbol("RUNMQ_INSTANCE");
|
|
50
|
+
var RUNMQ_MODULE_OPTIONS = /* @__PURE__ */ Symbol("RUNMQ_MODULE_OPTIONS");
|
|
51
|
+
var RUNMQ_PROCESSOR_METADATA = "RUNMQ_PROCESSOR";
|
|
52
|
+
var RUNMQ_HANDLER_METADATA = "RUNMQ_HANDLER";
|
|
53
|
+
|
|
54
|
+
// src/runmq.service.ts
|
|
55
|
+
import { Injectable, Inject, Logger } from "@nestjs/common";
|
|
56
|
+
var RunMQService = class {
|
|
57
|
+
constructor(_instance) {
|
|
58
|
+
this._instance = _instance;
|
|
59
|
+
this.logger = new Logger(RunMQService.name);
|
|
60
|
+
}
|
|
61
|
+
async onModuleDestroy() {
|
|
62
|
+
try {
|
|
63
|
+
await this._instance.disconnect();
|
|
64
|
+
} catch (error) {
|
|
65
|
+
this.logger.error(
|
|
66
|
+
`RunMQ disconnect error: ${error instanceof Error ? error.message : String(error)}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get instance() {
|
|
71
|
+
return this._instance;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
RunMQService = __decorateClass([
|
|
75
|
+
Injectable(),
|
|
76
|
+
__decorateParam(0, Inject(RUNMQ_INSTANCE))
|
|
77
|
+
], RunMQService);
|
|
78
|
+
|
|
79
|
+
// src/runmq-explorer.service.ts
|
|
80
|
+
import { Injectable as Injectable2, Inject as Inject2 } from "@nestjs/common";
|
|
81
|
+
import { DiscoveryService } from "@nestjs/core";
|
|
82
|
+
var RunMQExplorerService = class {
|
|
83
|
+
constructor(discoveryService, runmq) {
|
|
84
|
+
this.discoveryService = discoveryService;
|
|
85
|
+
this.runmq = runmq;
|
|
86
|
+
}
|
|
87
|
+
async onModuleInit() {
|
|
88
|
+
var _b;
|
|
89
|
+
const providers = this.discoveryService.getProviders();
|
|
90
|
+
const registeredNames = /* @__PURE__ */ new Set();
|
|
91
|
+
for (const wrapper of providers) {
|
|
92
|
+
const { instance, metatype } = wrapper;
|
|
93
|
+
if (!instance || !metatype) continue;
|
|
94
|
+
const processorOptions = Reflect.getMetadata(RUNMQ_PROCESSOR_METADATA, metatype);
|
|
95
|
+
if (!processorOptions) continue;
|
|
96
|
+
const className = metatype.name;
|
|
97
|
+
if (registeredNames.has(processorOptions.name)) {
|
|
98
|
+
throw new Error(`Duplicate processor name: ${processorOptions.name}`);
|
|
99
|
+
}
|
|
100
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
101
|
+
const methodNames = Object.getOwnPropertyNames(prototype).filter(
|
|
102
|
+
(key) => key !== "constructor"
|
|
103
|
+
);
|
|
104
|
+
const handlerMethods = methodNames.filter(
|
|
105
|
+
(key) => Reflect.getMetadata(RUNMQ_HANDLER_METADATA, prototype, key)
|
|
106
|
+
);
|
|
107
|
+
if (handlerMethods.length === 0) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`No @ProcessMessage handler found in ${className}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (handlerMethods.length > 1) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Multiple @ProcessMessage handlers in ${className}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
registeredNames.add(processorOptions.name);
|
|
118
|
+
const handlerName = handlerMethods[0];
|
|
119
|
+
const handler = instance[handlerName].bind(instance);
|
|
120
|
+
const _a = processorOptions, { topic } = _a, config = __objRest(_a, ["topic"]);
|
|
121
|
+
await this.runmq.process(
|
|
122
|
+
topic,
|
|
123
|
+
__spreadProps(__spreadValues({}, config), { consumersCount: (_b = config.consumersCount) != null ? _b : 1 }),
|
|
124
|
+
handler
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
RunMQExplorerService = __decorateClass([
|
|
130
|
+
Injectable2(),
|
|
131
|
+
__decorateParam(0, Inject2(DiscoveryService)),
|
|
132
|
+
__decorateParam(1, Inject2(RUNMQ_INSTANCE))
|
|
133
|
+
], RunMQExplorerService);
|
|
134
|
+
|
|
135
|
+
// src/runmq-publisher.service.ts
|
|
136
|
+
import { Injectable as Injectable3, Inject as Inject3 } from "@nestjs/common";
|
|
137
|
+
var RunMQPublisherService = class {
|
|
138
|
+
constructor(runmq) {
|
|
139
|
+
this.runmq = runmq;
|
|
140
|
+
}
|
|
141
|
+
publish(topic, message, correlationId) {
|
|
142
|
+
if (!this.runmq.isActive()) {
|
|
143
|
+
throw new Error("RunMQ is not connected");
|
|
144
|
+
}
|
|
145
|
+
this.runmq.publish(topic, message, correlationId);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
RunMQPublisherService = __decorateClass([
|
|
149
|
+
Injectable3(),
|
|
150
|
+
__decorateParam(0, Inject3(RUNMQ_INSTANCE))
|
|
151
|
+
], RunMQPublisherService);
|
|
152
|
+
|
|
153
|
+
// src/logger-adapter.ts
|
|
154
|
+
import { Logger as Logger2 } from "@nestjs/common";
|
|
155
|
+
var NestJSRunMQLogger = class {
|
|
156
|
+
constructor() {
|
|
157
|
+
this.logger = new Logger2("RunMQ");
|
|
158
|
+
}
|
|
159
|
+
log(message, ...optionalParams) {
|
|
160
|
+
this.logger.log(message, ...optionalParams);
|
|
161
|
+
}
|
|
162
|
+
error(message, ...optionalParams) {
|
|
163
|
+
this.logger.error(message, ...optionalParams);
|
|
164
|
+
}
|
|
165
|
+
warn(message, ...optionalParams) {
|
|
166
|
+
this.logger.warn(message, ...optionalParams);
|
|
167
|
+
}
|
|
168
|
+
info(message, ...optionalParams) {
|
|
169
|
+
this.logger.log(message, ...optionalParams);
|
|
170
|
+
}
|
|
171
|
+
debug(message, ...optionalParams) {
|
|
172
|
+
this.logger.debug(message, ...optionalParams);
|
|
173
|
+
}
|
|
174
|
+
verbose(message, ...optionalParams) {
|
|
175
|
+
this.logger.verbose(message, ...optionalParams);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// src/runmq.module.ts
|
|
180
|
+
var RunMQModule = class {
|
|
181
|
+
static forRoot(options) {
|
|
182
|
+
return RunMQModule.buildDynamicModule(
|
|
183
|
+
[{ provide: RUNMQ_MODULE_OPTIONS, useValue: options }]
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
static forRootAsync(options) {
|
|
187
|
+
return RunMQModule.buildDynamicModule(
|
|
188
|
+
RunMQModule.createAsyncProviders(options),
|
|
189
|
+
options.imports
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
static buildDynamicModule(optionsProviders, extraImports = []) {
|
|
193
|
+
return {
|
|
194
|
+
global: true,
|
|
195
|
+
module: RunMQModule,
|
|
196
|
+
imports: [DiscoveryModule, ...extraImports],
|
|
197
|
+
providers: [
|
|
198
|
+
...optionsProviders,
|
|
199
|
+
{
|
|
200
|
+
provide: RUNMQ_INSTANCE,
|
|
201
|
+
useFactory: async (options) => RunMQ.start(options, new NestJSRunMQLogger()),
|
|
202
|
+
inject: [RUNMQ_MODULE_OPTIONS]
|
|
203
|
+
},
|
|
204
|
+
RunMQService,
|
|
205
|
+
RunMQExplorerService,
|
|
206
|
+
RunMQPublisherService
|
|
207
|
+
],
|
|
208
|
+
exports: [RunMQService, RUNMQ_INSTANCE, RunMQPublisherService]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
static createAsyncProviders(options) {
|
|
212
|
+
var _a;
|
|
213
|
+
if (options.useFactory) {
|
|
214
|
+
return [
|
|
215
|
+
{
|
|
216
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
217
|
+
useFactory: options.useFactory,
|
|
218
|
+
inject: (_a = options.inject) != null ? _a : []
|
|
219
|
+
}
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
if (options.useClass) {
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
226
|
+
useFactory: async (factory) => factory.createRunMQOptions(),
|
|
227
|
+
inject: [options.useClass]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
provide: options.useClass,
|
|
231
|
+
useClass: options.useClass
|
|
232
|
+
}
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
if (options.useExisting) {
|
|
236
|
+
return [
|
|
237
|
+
{
|
|
238
|
+
provide: RUNMQ_MODULE_OPTIONS,
|
|
239
|
+
useFactory: async (factory) => factory.createRunMQOptions(),
|
|
240
|
+
inject: [options.useExisting]
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
}
|
|
244
|
+
throw new Error(
|
|
245
|
+
"RunMQModule.forRootAsync() requires useFactory, useClass, or useExisting"
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
RunMQModule = __decorateClass([
|
|
250
|
+
Module({})
|
|
251
|
+
], RunMQModule);
|
|
252
|
+
|
|
253
|
+
// src/decorators/processor.decorator.ts
|
|
254
|
+
import "reflect-metadata";
|
|
255
|
+
function Processor(options) {
|
|
256
|
+
return (target) => {
|
|
257
|
+
Reflect.defineMetadata(RUNMQ_PROCESSOR_METADATA, options, target);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/decorators/process-message.decorator.ts
|
|
262
|
+
import "reflect-metadata";
|
|
263
|
+
function ProcessMessage() {
|
|
264
|
+
return (target, propertyKey) => {
|
|
265
|
+
Reflect.defineMetadata(RUNMQ_HANDLER_METADATA, propertyKey, target, propertyKey);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/decorators/inject-runmq.decorator.ts
|
|
270
|
+
import { Inject as Inject4 } from "@nestjs/common";
|
|
271
|
+
var InjectRunMQ = () => Inject4(RUNMQ_INSTANCE);
|
|
272
|
+
|
|
273
|
+
// src/index.ts
|
|
274
|
+
import { RunMQ as RunMQ2 } from "runmq";
|
|
275
|
+
export {
|
|
276
|
+
InjectRunMQ,
|
|
277
|
+
ProcessMessage,
|
|
278
|
+
Processor,
|
|
279
|
+
RunMQ2 as RunMQ,
|
|
280
|
+
RunMQModule,
|
|
281
|
+
RunMQPublisherService,
|
|
282
|
+
RunMQService
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runmq.module.ts","../src/constants.ts","../src/runmq.service.ts","../src/runmq-explorer.service.ts","../src/runmq-publisher.service.ts","../src/logger-adapter.ts","../src/decorators/processor.decorator.ts","../src/decorators/process-message.decorator.ts","../src/decorators/inject-runmq.decorator.ts","../src/index.ts"],"sourcesContent":["import { DynamicModule, Module, Provider } from '@nestjs/common';\nimport { DiscoveryModule } from '@nestjs/core';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE, RUNMQ_MODULE_OPTIONS } from './constants';\nimport { RunMQModuleOptions, RunMQOptionsFactory } from './interfaces/runmq-module-options.interface';\nimport { RunMQAsyncModuleOptions } from './interfaces/runmq-async-options.interface';\nimport { RunMQService } from './runmq.service';\nimport { RunMQExplorerService } from './runmq-explorer.service';\nimport { RunMQPublisherService } from './runmq-publisher.service';\nimport { NestJSRunMQLogger } from './logger-adapter';\n\n@Module({})\nexport class RunMQModule {\n static forRoot(options: RunMQModuleOptions): DynamicModule {\n return RunMQModule.buildDynamicModule(\n [{ provide: RUNMQ_MODULE_OPTIONS, useValue: options }],\n );\n }\n\n static forRootAsync(options: RunMQAsyncModuleOptions): DynamicModule {\n return RunMQModule.buildDynamicModule(\n RunMQModule.createAsyncProviders(options),\n options.imports,\n );\n }\n\n private static buildDynamicModule(\n optionsProviders: Provider[],\n extraImports: any[] = [],\n ): DynamicModule {\n return {\n global: true,\n module: RunMQModule,\n imports: [DiscoveryModule, ...extraImports],\n providers: [\n ...optionsProviders,\n {\n provide: RUNMQ_INSTANCE,\n useFactory: async (options: RunMQModuleOptions) =>\n RunMQ.start(options, new NestJSRunMQLogger()),\n inject: [RUNMQ_MODULE_OPTIONS],\n },\n RunMQService,\n RunMQExplorerService,\n RunMQPublisherService,\n ],\n exports: [RunMQService, RUNMQ_INSTANCE, RunMQPublisherService],\n };\n }\n\n private static createAsyncProviders(options: RunMQAsyncModuleOptions): Provider[] {\n if (options.useFactory) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: options.useFactory,\n inject: options.inject ?? [],\n },\n ];\n }\n\n if (options.useClass) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: async (factory: RunMQOptionsFactory) =>\n factory.createRunMQOptions(),\n inject: [options.useClass],\n },\n {\n provide: options.useClass,\n useClass: options.useClass,\n },\n ];\n }\n\n if (options.useExisting) {\n return [\n {\n provide: RUNMQ_MODULE_OPTIONS,\n useFactory: async (factory: RunMQOptionsFactory) =>\n factory.createRunMQOptions(),\n inject: [options.useExisting],\n },\n ];\n }\n\n throw new Error(\n 'RunMQModule.forRootAsync() requires useFactory, useClass, or useExisting',\n );\n }\n}\n","export const RUNMQ_INSTANCE = Symbol('RUNMQ_INSTANCE');\nexport const RUNMQ_MODULE_OPTIONS = Symbol('RUNMQ_MODULE_OPTIONS');\n\nexport const RUNMQ_PROCESSOR_METADATA = 'RUNMQ_PROCESSOR';\nexport const RUNMQ_HANDLER_METADATA = 'RUNMQ_HANDLER';\n","import { Injectable, Inject, OnModuleDestroy, Logger } from '@nestjs/common';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE } from './constants';\n\n@Injectable()\nexport class RunMQService implements OnModuleDestroy {\n private readonly logger = new Logger(RunMQService.name);\n\n constructor(\n @Inject(RUNMQ_INSTANCE) private readonly _instance: RunMQ,\n ) {}\n\n async onModuleDestroy(): Promise<void> {\n try {\n await this._instance.disconnect();\n } catch (error) {\n this.logger.error(\n `RunMQ disconnect error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n\n get instance(): RunMQ {\n return this._instance;\n }\n}\n","import { Injectable, Inject, OnModuleInit } from '@nestjs/common';\nimport { DiscoveryService } from '@nestjs/core';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_PROCESSOR_METADATA, RUNMQ_HANDLER_METADATA, RUNMQ_INSTANCE } from './constants';\nimport type { ProcessorDecoratorOptions } from './decorators/processor.decorator';\n\n@Injectable()\nexport class RunMQExplorerService implements OnModuleInit {\n constructor(\n @Inject(DiscoveryService) private readonly discoveryService: DiscoveryService,\n @Inject(RUNMQ_INSTANCE) private readonly runmq: RunMQ,\n ) {}\n\n async onModuleInit(): Promise<void> {\n const providers = this.discoveryService.getProviders();\n const registeredNames = new Set<string>();\n\n for (const wrapper of providers) {\n const { instance, metatype } = wrapper;\n\n if (!instance || !metatype) continue;\n\n const processorOptions: ProcessorDecoratorOptions | undefined =\n Reflect.getMetadata(RUNMQ_PROCESSOR_METADATA, metatype);\n\n if (!processorOptions) continue;\n\n const className = metatype.name;\n\n // Check for duplicate processor names\n if (registeredNames.has(processorOptions.name)) {\n throw new Error(`Duplicate processor name: ${processorOptions.name}`);\n }\n\n // Find method decorated with @ProcessMessage()\n const prototype = Object.getPrototypeOf(instance);\n const methodNames = Object.getOwnPropertyNames(prototype).filter(\n (key) => key !== 'constructor',\n );\n\n const handlerMethods = methodNames.filter((key) =>\n Reflect.getMetadata(RUNMQ_HANDLER_METADATA, prototype, key),\n );\n\n if (handlerMethods.length === 0) {\n throw new Error(\n `No @ProcessMessage handler found in ${className}`,\n );\n }\n\n if (handlerMethods.length > 1) {\n throw new Error(\n `Multiple @ProcessMessage handlers in ${className}`,\n );\n }\n\n registeredNames.add(processorOptions.name);\n\n const handlerName = handlerMethods[0];\n const handler = instance[handlerName].bind(instance);\n\n const { topic, ...config } = processorOptions;\n await this.runmq.process(\n topic,\n { ...config, consumersCount: config.consumersCount ?? 1 },\n handler,\n );\n }\n }\n}\n","import { Injectable, Inject } from '@nestjs/common';\nimport { RunMQ } from 'runmq';\nimport { RUNMQ_INSTANCE } from './constants';\n\n@Injectable()\nexport class RunMQPublisherService {\n constructor(\n @Inject(RUNMQ_INSTANCE) private readonly runmq: RunMQ,\n ) {}\n\n publish(topic: string, message: Record<string, any>, correlationId?: string): void {\n if (!this.runmq.isActive()) {\n throw new Error('RunMQ is not connected');\n }\n this.runmq.publish(topic, message, correlationId);\n }\n}\n","import { Logger } from '@nestjs/common';\nimport type { RunMQLogger } from 'runmq';\n\nexport class NestJSRunMQLogger implements RunMQLogger {\n private readonly logger = new Logger('RunMQ');\n\n log(message: string, ...optionalParams: any[]): void {\n this.logger.log(message, ...optionalParams);\n }\n\n error(message: string, ...optionalParams: any[]): void {\n this.logger.error(message, ...optionalParams);\n }\n\n warn(message: string, ...optionalParams: any[]): void {\n this.logger.warn(message, ...optionalParams);\n }\n\n info(message: string, ...optionalParams: any[]): void {\n this.logger.log(message, ...optionalParams);\n }\n\n debug(message: string, ...optionalParams: any[]): void {\n this.logger.debug(message, ...optionalParams);\n }\n\n verbose(message: string, ...optionalParams: any[]): void {\n this.logger.verbose(message, ...optionalParams);\n }\n}\n","import 'reflect-metadata';\nimport { RUNMQ_PROCESSOR_METADATA } from '../constants';\nimport type { MessageSchema } from 'runmq';\n\nexport interface ProcessorDecoratorOptions {\n topic: string;\n name: string;\n consumersCount?: number;\n attempts?: number;\n attemptsDelay?: number;\n messageSchema?: MessageSchema;\n usePoliciesForDelay?: boolean;\n}\n\nexport function Processor(options: ProcessorDecoratorOptions): ClassDecorator {\n return (target) => {\n Reflect.defineMetadata(RUNMQ_PROCESSOR_METADATA, options, target);\n };\n}\n","import 'reflect-metadata';\nimport { RUNMQ_HANDLER_METADATA } from '../constants';\n\nexport function ProcessMessage(): MethodDecorator {\n return (target, propertyKey) => {\n Reflect.defineMetadata(RUNMQ_HANDLER_METADATA, propertyKey, target, propertyKey);\n };\n}\n","import { Inject } from '@nestjs/common';\nimport { RUNMQ_INSTANCE } from '../constants';\n\nexport const InjectRunMQ = (): ParameterDecorator => Inject(RUNMQ_INSTANCE);\n","export { RunMQModule } from './runmq.module';\n\nexport { RunMQService } from './runmq.service';\nexport { RunMQPublisherService } from './runmq-publisher.service';\n\nexport { Processor } from './decorators/processor.decorator';\nexport { ProcessMessage } from './decorators/process-message.decorator';\nexport { InjectRunMQ } from './decorators/inject-runmq.decorator';\n\nexport type { RunMQModuleOptions, RunMQOptionsFactory } from './interfaces/runmq-module-options.interface';\nexport type { RunMQAsyncModuleOptions } from './interfaces/runmq-async-options.interface';\nexport type { ProcessorDecoratorOptions } from './decorators/processor.decorator';\n\nexport type {\n RunMQMessageContent,\n RunMQMessageMetaContent,\n RunMQConnectionConfig,\n RunMQProcessorConfiguration,\n MessageSchema,\n SchemaType,\n SchemaFailureStrategy,\n RabbitMQManagementConfig,\n RunMQLogger,\n RunMQQueueMetadata,\n} from 'runmq';\nexport { RunMQ } from 'runmq';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAwB,cAAwB;AAChD,SAAS,uBAAuB;AAChC,SAAS,aAAa;;;ACFf,IAAM,iBAAiB,uBAAO,gBAAgB;AAC9C,IAAM,uBAAuB,uBAAO,sBAAsB;AAE1D,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;;;ACJtC,SAAS,YAAY,QAAyB,cAAc;AAKrD,IAAM,eAAN,MAA8C;AAAA,EAGnD,YAC2C,WACzC;AADyC;AAH3C,SAAiB,SAAS,IAAI,OAAO,aAAa,IAAI;AAAA,EAInD;AAAA,EAEH,MAAM,kBAAiC;AACrC,QAAI;AACF,YAAM,KAAK,UAAU,WAAW;AAAA,IAClC,SAAS,OAAO;AACd,WAAK,OAAO;AAAA,QACV,2BAA2B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAAA,E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AA,UACjB,UAAU,QAAQ;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,QAAQ,aAAa;AACvB,aAAO;AAAA,QACL;AAAA,UACE,SAAS;AAAA,UACT,YAAY,OAAO,YACjB,QAAQ,mBAAmB;AAAA,UAC7B,QAAQ,CAAC,QAAQ,WAAW;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AA/Ea,cAAN;AAAA,EADN,OAAO,CAAC,CAAC;AAAA,GACG;;;AMZb,OAAO;AAcA,SAAS,UAAU,SAAoD;AAC5E,SAAO,CAAC,WAAW;AACjB,YAAQ,eAAe,0BAA0B,SAAS,MAAM;AAAA,EAClE;AACF;;;AClBA,OAAO;AAGA,SAAS,iBAAkC;AAChD,SAAO,CAAC,QAAQ,gBAAgB;AAC9B,YAAQ,eAAe,wBAAwB,aAAa,QAAQ,WAAW;AAAA,EACjF;AACF;;;ACPA,SAAS,UAAAC,eAAc;AAGhB,IAAM,cAAc,MAA0BC,QAAO,cAAc;;;ACsB1E,SAAS,SAAAC,cAAa;","names":["Injectable","Inject","Injectable","Inject","Injectable","Inject","Injectable","Inject","Logger","Inject","Inject","RunMQ"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nestjs-runmq",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "NestJS module for RunMQ - a reliable, high-performance message queue library for Node.js, built on top of RabbitMQ",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"nestjs",
|
|
8
|
+
"runmq",
|
|
9
|
+
"rabbitmq",
|
|
10
|
+
"message-queue",
|
|
11
|
+
"processors",
|
|
12
|
+
"microservices",
|
|
13
|
+
"decorator"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.cjs",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup src/index.ts",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"lint:fix": "eslint --fix .",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:unit": "jest tests/unit",
|
|
34
|
+
"test:integration": "jest tests/integration",
|
|
35
|
+
"test:coverage": "jest --coverage"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@nestjs/common": ">=10.0.0",
|
|
39
|
+
"@nestjs/core": ">=10.0.0",
|
|
40
|
+
"reflect-metadata": ">=0.1.0",
|
|
41
|
+
"runmq": ">=1.4.0",
|
|
42
|
+
"rxjs": ">=7.0.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/runmq/nestjs.git"
|
|
47
|
+
},
|
|
48
|
+
"author": "https://github.com/iifawzi",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/runmq/nestjs/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/runmq/nestjs#readme",
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@nestjs/common": "^10.0.0",
|
|
59
|
+
"@nestjs/core": "^10.0.0",
|
|
60
|
+
"@nestjs/testing": "^10.0.0",
|
|
61
|
+
"@eslint/js": "^9.29.0",
|
|
62
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
63
|
+
"@semantic-release/commit-analyzer": "^10.0.4",
|
|
64
|
+
"@semantic-release/git": "^10.0.1",
|
|
65
|
+
"@semantic-release/github": "^11.0.1",
|
|
66
|
+
"@semantic-release/release-notes-generator": "^11.0.7",
|
|
67
|
+
"@types/jest": "^30.0.0",
|
|
68
|
+
"@types/node": "^22.0.0",
|
|
69
|
+
"@types/supertest": "^6.0.0",
|
|
70
|
+
"eslint": "^9.29.0",
|
|
71
|
+
"globals": "^16.0.0",
|
|
72
|
+
"jest": "^30.0.3",
|
|
73
|
+
"reflect-metadata": "^0.2.2",
|
|
74
|
+
"runmq": "^1.4.0",
|
|
75
|
+
"rxjs": "^7.8.0",
|
|
76
|
+
"semantic-release": "^24.2.0",
|
|
77
|
+
"supertest": "^7.0.0",
|
|
78
|
+
"ts-jest": "^29.4.0",
|
|
79
|
+
"ts-node": "^10.9.2",
|
|
80
|
+
"tsup": "^8.5.0",
|
|
81
|
+
"typescript": "^5.8.3",
|
|
82
|
+
"typescript-eslint": "^8.35.0"
|
|
83
|
+
},
|
|
84
|
+
"release": {
|
|
85
|
+
"branches": [
|
|
86
|
+
"main"
|
|
87
|
+
],
|
|
88
|
+
"plugins": [
|
|
89
|
+
"@semantic-release/commit-analyzer",
|
|
90
|
+
"@semantic-release/release-notes-generator",
|
|
91
|
+
"@semantic-release/changelog",
|
|
92
|
+
[
|
|
93
|
+
"@semantic-release/github",
|
|
94
|
+
{
|
|
95
|
+
"assets": [
|
|
96
|
+
{
|
|
97
|
+
"path": "dist.zip",
|
|
98
|
+
"label": "Distribution"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"@semantic-release/git",
|
|
105
|
+
{
|
|
106
|
+
"assets": [
|
|
107
|
+
"package.json",
|
|
108
|
+
"CHANGELOG.md"
|
|
109
|
+
],
|
|
110
|
+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
}
|