@riaskov/nevo-messaging 1.1.2 → 1.1.4

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,20 @@ npm install @riaskov/nevo-messaging
28
28
  ### Peer Dependencies
29
29
 
30
30
  ```bash
31
- npm install @nestjs/common @nestjs/core @nestjs/microservices @nestjs/config @nestjs/platform-fastify kafkajs nats socket.io socket.io-client rxjs reflect-metadata
31
+ npm install @nestjs/common @nestjs/core @nestjs/microservices @nestjs/config @nestjs/platform-fastify rxjs reflect-metadata
32
+ ```
33
+
34
+ Transport-specific deps (install only what you use):
35
+
36
+ ```bash
37
+ # Kafka
38
+ npm install kafkajs
39
+
40
+ # NATS
41
+ npm install nats
42
+
43
+ # Socket.IO
44
+ npm install socket.io socket.io-client
32
45
  ```
33
46
 
34
47
  ## Quick Start
@@ -114,15 +127,14 @@ Start your service:
114
127
 
115
128
  ```typescript
116
129
  // main.ts
117
- import { NestFactory } from "@nestjs/core"
130
+ import { createNatsMicroservice } from "@riaskov/nevo-messaging"
118
131
  import { AppModule } from "./app.module"
119
132
 
120
- async function bootstrap() {
121
- const app = await NestFactory.create(AppModule)
122
- await app.listen(8086)
123
- }
124
-
125
- bootstrap()
133
+ createNatsMicroservice({
134
+ microserviceName: "user",
135
+ module: AppModule,
136
+ port: 8086
137
+ }).then()
126
138
  ```
127
139
  ## Core Concepts
128
140
 
@@ -426,6 +438,14 @@ createKafkaMicroservice({
426
438
  })
427
439
  ```
428
440
 
441
+ Same options apply to:
442
+
443
+ ```typescript
444
+ createNatsMicroservice({ microserviceName: "user", module: AppModule, port: 8087 }).then()
445
+ createSocketMicroservice({ microserviceName: "user", module: AppModule, port: 8088 }).then()
446
+ createHttpMicroservice({ microserviceName: "user", module: AppModule, port: 8089 }).then()
447
+ ```
448
+
429
449
  ## Transports
430
450
 
431
451
  | Transport | Patterns | Discovery | Infra | Notes |
@@ -445,6 +465,12 @@ createNevoNatsClient(["USER", "COORDINATOR"], {
445
465
  })
446
466
  ```
447
467
 
468
+ Quick bootstrap:
469
+
470
+ ```typescript
471
+ createNatsMicroservice({ microserviceName: "user", module: AppModule, port: 8087 }).then()
472
+ ```
473
+
448
474
  Controller decorator:
449
475
 
450
476
  ```typescript
@@ -463,6 +489,12 @@ Socket.IO server is started inside the router decorator:
463
489
  export class UserController {}
464
490
  ```
465
491
 
492
+ Quick bootstrap:
493
+
494
+ ```typescript
495
+ createSocketMicroservice({ microserviceName: "user", module: AppModule, port: 8092 }).then()
496
+ ```
497
+
466
498
  Client:
467
499
 
468
500
  ```typescript
@@ -486,6 +518,12 @@ Include transport controller to enable SSE + publish endpoints:
486
518
  controllers: [UserController, HttpTransportController]
487
519
  ```
488
520
 
521
+ Quick bootstrap:
522
+
523
+ ```typescript
524
+ createHttpMicroservice({ microserviceName: "user", module: AppModule, port: 8090 }).then()
525
+ ```
526
+
489
527
  Client:
490
528
 
491
529
  ```typescript
@@ -3,3 +3,4 @@ export * from "./http.client-base";
3
3
  export * from "./http.signal-router.decorator";
4
4
  export * from "./http.transport.controller";
5
5
  export * from "./http.config";
6
+ export * from "./microservice.config";
@@ -19,3 +19,4 @@ __exportStar(require("./http.client-base"), exports);
19
19
  __exportStar(require("./http.signal-router.decorator"), exports);
20
20
  __exportStar(require("./http.transport.controller"), exports);
21
21
  __exportStar(require("./http.config"), exports);
22
+ __exportStar(require("./microservice.config"), exports);
@@ -0,0 +1,3 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { NestApplicationOptions } from "../microservice.options";
3
+ export declare function createHttpMicroservice(options: NestApplicationOptions): Promise<INestApplication>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createHttpMicroservice = createHttpMicroservice;
4
+ const core_1 = require("@nestjs/core");
5
+ const platform_fastify_1 = require("@nestjs/platform-fastify");
6
+ async function createHttpMicroservice(options) {
7
+ // @ts-ignore
8
+ const { microserviceName, module, port = 3000, host = "0.0.0.0", debug = process.env["NODE_ENV"] !== "production", onInit } = options;
9
+ const app = await core_1.NestFactory.create(module, new platform_fastify_1.FastifyAdapter());
10
+ if (onInit) {
11
+ await onInit(app);
12
+ }
13
+ await app.listen(port, host);
14
+ console.log(`Service started on http://${host === "0.0.0.0" ? "localhost" : host}:${port}`);
15
+ return app;
16
+ }
@@ -2,3 +2,4 @@ export * from "./kafka";
2
2
  export * from "./nats";
3
3
  export * from "./http";
4
4
  export * from "./socket-io";
5
+ export * from "./microservice.options";
@@ -18,3 +18,4 @@ __exportStar(require("./kafka"), exports);
18
18
  __exportStar(require("./nats"), exports);
19
19
  __exportStar(require("./http"), exports);
20
20
  __exportStar(require("./socket-io"), exports);
21
+ __exportStar(require("./microservice.options"), exports);
@@ -1,10 +1,3 @@
1
- import { INestApplication, Type } from "@nestjs/common";
2
- export interface NestApplicationOptions {
3
- microserviceName: string;
4
- module: Type<any>;
5
- port?: number;
6
- host?: string;
7
- debug?: boolean;
8
- onInit?: (app: INestApplication) => Promise<void>;
9
- }
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { NestApplicationOptions } from "../microservice.options";
10
3
  export declare function createKafkaMicroservice(options: NestApplicationOptions): Promise<INestApplication>;
@@ -0,0 +1,9 @@
1
+ import { INestApplication, Type } from "@nestjs/common";
2
+ export interface NestApplicationOptions {
3
+ microserviceName: string;
4
+ module: Type<any>;
5
+ port?: number;
6
+ host?: string;
7
+ debug?: boolean;
8
+ onInit?: (app: INestApplication) => Promise<void>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,3 +2,4 @@ export * from "./nevo-nats.client";
2
2
  export * from "./nats.client-base";
3
3
  export * from "./nats.config";
4
4
  export * from "./nats.signal-router.decorator";
5
+ export * from "./microservice.config";
@@ -18,3 +18,4 @@ __exportStar(require("./nevo-nats.client"), exports);
18
18
  __exportStar(require("./nats.client-base"), exports);
19
19
  __exportStar(require("./nats.config"), exports);
20
20
  __exportStar(require("./nats.signal-router.decorator"), exports);
21
+ __exportStar(require("./microservice.config"), exports);
@@ -0,0 +1,3 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { NestApplicationOptions } from "../microservice.options";
3
+ export declare function createNatsMicroservice(options: NestApplicationOptions): Promise<INestApplication>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNatsMicroservice = createNatsMicroservice;
4
+ const core_1 = require("@nestjs/core");
5
+ const platform_fastify_1 = require("@nestjs/platform-fastify");
6
+ async function createNatsMicroservice(options) {
7
+ // @ts-ignore
8
+ const { microserviceName, module, port = 3000, host = "0.0.0.0", debug = process.env["NODE_ENV"] !== "production", onInit } = options;
9
+ const app = await core_1.NestFactory.create(module, new platform_fastify_1.FastifyAdapter());
10
+ if (onInit) {
11
+ await onInit(app);
12
+ }
13
+ await app.listen(port, host);
14
+ console.log(`Service started on http://${host === "0.0.0.0" ? "localhost" : host}:${port}`);
15
+ return app;
16
+ }
@@ -2,3 +2,4 @@ export * from "./nevo-socket.client";
2
2
  export * from "./socket.client-base";
3
3
  export * from "./socket.signal-router.decorator";
4
4
  export * from "./socket.config";
5
+ export * from "./microservice.config";
@@ -18,3 +18,4 @@ __exportStar(require("./nevo-socket.client"), exports);
18
18
  __exportStar(require("./socket.client-base"), exports);
19
19
  __exportStar(require("./socket.signal-router.decorator"), exports);
20
20
  __exportStar(require("./socket.config"), exports);
21
+ __exportStar(require("./microservice.config"), exports);
@@ -0,0 +1,3 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { NestApplicationOptions } from "../microservice.options";
3
+ export declare function createSocketMicroservice(options: NestApplicationOptions): Promise<INestApplication>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSocketMicroservice = createSocketMicroservice;
4
+ const core_1 = require("@nestjs/core");
5
+ const platform_fastify_1 = require("@nestjs/platform-fastify");
6
+ async function createSocketMicroservice(options) {
7
+ // @ts-ignore
8
+ const { microserviceName, module, port = 3000, host = "0.0.0.0", debug = process.env["NODE_ENV"] !== "production", onInit } = options;
9
+ const app = await core_1.NestFactory.create(module, new platform_fastify_1.FastifyAdapter());
10
+ if (onInit) {
11
+ await onInit(app);
12
+ }
13
+ await app.listen(port, host);
14
+ console.log(`Service started on http://${host === "0.0.0.0" ? "localhost" : host}:${port}`);
15
+ return app;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riaskov/nevo-messaging",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Microservices messaging framework for NestJS with NATS/Kafka/SocketIO transport",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,20 @@
35
35
  "socket.io": "^4.8.1",
36
36
  "socket.io-client": "^4.8.1"
37
37
  },
38
+ "peerDependenciesMeta": {
39
+ "kafkajs": {
40
+ "optional": true
41
+ },
42
+ "nats": {
43
+ "optional": true
44
+ },
45
+ "socket.io": {
46
+ "optional": true
47
+ },
48
+ "socket.io-client": {
49
+ "optional": true
50
+ }
51
+ },
38
52
  "devDependencies": {
39
53
  "@nestjs/common": "11.1.0",
40
54
  "@nestjs/core": "11.1.0",