@nestjstools/messaging 2.9.1 → 2.9.2
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 +10 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,10 +43,10 @@ yarn add @nestjstools/messaging
|
|
|
43
43
|
### Basic Usage (In-memory)
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
|
-
import { MessagingModule } from '@nestjstools/messaging';
|
|
47
|
-
import { InMemoryChannelConfig } from '@nestjstools/messaging/channels';
|
|
46
|
+
import { MessagingModule, InMemoryChannelConfig } from '@nestjstools/messaging';
|
|
48
47
|
import { SendMessageHandler } from './handlers/send-message.handler';
|
|
49
48
|
|
|
49
|
+
|
|
50
50
|
@Module({
|
|
51
51
|
imports: [
|
|
52
52
|
MessagingModule.forRoot({
|
|
@@ -86,11 +86,10 @@ export class SendMessage {
|
|
|
86
86
|
#### Define your message handler
|
|
87
87
|
```typescript
|
|
88
88
|
import { SendMessage } from './send-message';
|
|
89
|
-
import { MessageResponse } from '@nestjstools/messaging
|
|
90
|
-
import { MessageHandler } from '@nestjstools/messaging/decorators';
|
|
91
|
-
import { IMessageHandler } from '@nestjstools/messaging/interfaces';
|
|
89
|
+
import { MessageResponse, MessageHandler, IMessageHandler } from '@nestjstools/messaging';
|
|
92
90
|
import { Injectable } from '@nestjs/common';
|
|
93
91
|
|
|
92
|
+
|
|
94
93
|
@Injectable()
|
|
95
94
|
@MessageHandler('your.message')
|
|
96
95
|
export class SendMessageHandler implements IMessageHandler<SendMessage> {
|
|
@@ -107,11 +106,10 @@ Messages can be dispatched from anywhere in your application—whether from serv
|
|
|
107
106
|
|
|
108
107
|
```typescript
|
|
109
108
|
import { Controller, Get } from '@nestjs/common';
|
|
110
|
-
import { MessageBus } from '@nestjstools/messaging
|
|
111
|
-
import { IMessageBus } from '@nestjstools/messaging/bus';
|
|
112
|
-
import { RoutingMessage } from '@nestjstools/messaging/message';
|
|
109
|
+
import { MessageBus, IMessageBus, RoutingMessage } from '@nestjstools/messaging';
|
|
113
110
|
import { SendMessage } from './test/send-message';
|
|
114
111
|
|
|
112
|
+
|
|
115
113
|
@Controller()
|
|
116
114
|
export class AppController {
|
|
117
115
|
//You can inject every bus which you defined in configuration
|
|
@@ -170,10 +168,10 @@ yarn add @nestjstools/messaging-rabbitmq-extension
|
|
|
170
168
|
```
|
|
171
169
|
|
|
172
170
|
```typescript
|
|
173
|
-
import { MessagingModule } from '@nestjstools/messaging';
|
|
174
|
-
import { InMemoryChannelConfig, AmqpChannelConfig, ExchangeType } from '@nestjstools/messaging/channels';
|
|
171
|
+
import { MessagingModule, InMemoryChannelConfig, AmqpChannelConfig, ExchangeType } from '@nestjstools/messaging';
|
|
175
172
|
import { SendMessageHandler } from './handlers/send-message.handler';
|
|
176
173
|
|
|
174
|
+
|
|
177
175
|
@Module({
|
|
178
176
|
imports: [
|
|
179
177
|
MessagingModule.forRoot({
|
|
@@ -334,8 +332,7 @@ Here's an example middleware class that logs a message when the middleware is ap
|
|
|
334
332
|
|
|
335
333
|
```typescript
|
|
336
334
|
import { Injectable } from '@nestjs/common';
|
|
337
|
-
import { Middleware } from '@nestjstools/messaging
|
|
338
|
-
import { RoutingMessage } from '@nestjstools/messaging/message/routing-message';
|
|
335
|
+
import { Middleware, RoutingMessage } from '@nestjstools/messaging';
|
|
339
336
|
|
|
340
337
|
@Injectable()
|
|
341
338
|
@MessagingMiddleware()
|
|
@@ -353,8 +350,7 @@ export class TestMiddleware implements Middleware {
|
|
|
353
350
|
Now that we've defined the middleware, it needs to be attached to a specific channel in the `MessagingModule` configuration. Here's how you would configure the middleware for a channel:
|
|
354
351
|
|
|
355
352
|
```typescript
|
|
356
|
-
import { MessagingModule } from '@nestjstools/messaging';
|
|
357
|
-
import { AmqpChannelConfig, InMemoryChannelConfig } from '@nestjstools/messaging/channels';
|
|
353
|
+
import { MessagingModule, AmqpChannelConfig, InMemoryChannelConfig } from '@nestjstools/messaging';
|
|
358
354
|
import { TestMiddleware } from './middlewares/test.middleware';
|
|
359
355
|
import { SendMessageHandler } from './handlers/send-message.handler';
|
|
360
356
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjstools/messaging",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.2",
|
|
4
4
|
"description": "Simplifies asynchronous and synchronous message handling with support for buses, handlers, channels, and consumers. Build scalable, decoupled applications with ease and reliability.",
|
|
5
5
|
"author": "Sebastian Iwanczyszyn",
|
|
6
6
|
"license": "MIT",
|