@riaskov/nevo-messaging 1.1.2 → 1.1.3

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
@@ -114,15 +114,14 @@ Start your service:
114
114
 
115
115
  ```typescript
116
116
  // main.ts
117
- import { NestFactory } from "@nestjs/core"
117
+ import { createNatsMicroservice } from "@riaskov/nevo-messaging"
118
118
  import { AppModule } from "./app.module"
119
119
 
120
- async function bootstrap() {
121
- const app = await NestFactory.create(AppModule)
122
- await app.listen(8086)
123
- }
124
-
125
- bootstrap()
120
+ createNatsMicroservice({
121
+ microserviceName: "user",
122
+ module: AppModule,
123
+ port: 8086
124
+ }).then()
126
125
  ```
127
126
  ## Core Concepts
128
127
 
@@ -426,6 +425,14 @@ createKafkaMicroservice({
426
425
  })
427
426
  ```
428
427
 
428
+ Same options apply to:
429
+
430
+ ```typescript
431
+ createNatsMicroservice({ microserviceName: "user", module: AppModule, port: 8087 }).then()
432
+ createSocketMicroservice({ microserviceName: "user", module: AppModule, port: 8088 }).then()
433
+ createHttpMicroservice({ microserviceName: "user", module: AppModule, port: 8089 }).then()
434
+ ```
435
+
429
436
  ## Transports
430
437
 
431
438
  | Transport | Patterns | Discovery | Infra | Notes |
@@ -445,6 +452,12 @@ createNevoNatsClient(["USER", "COORDINATOR"], {
445
452
  })
446
453
  ```
447
454
 
455
+ Quick bootstrap:
456
+
457
+ ```typescript
458
+ createNatsMicroservice({ microserviceName: "user", module: AppModule, port: 8087 }).then()
459
+ ```
460
+
448
461
  Controller decorator:
449
462
 
450
463
  ```typescript
@@ -463,6 +476,12 @@ Socket.IO server is started inside the router decorator:
463
476
  export class UserController {}
464
477
  ```
465
478
 
479
+ Quick bootstrap:
480
+
481
+ ```typescript
482
+ createSocketMicroservice({ microserviceName: "user", module: AppModule, port: 8092 }).then()
483
+ ```
484
+
466
485
  Client:
467
486
 
468
487
  ```typescript
@@ -486,6 +505,12 @@ Include transport controller to enable SSE + publish endpoints:
486
505
  controllers: [UserController, HttpTransportController]
487
506
  ```
488
507
 
508
+ Quick bootstrap:
509
+
510
+ ```typescript
511
+ createHttpMicroservice({ microserviceName: "user", module: AppModule, port: 8090 }).then()
512
+ ```
513
+
489
514
  Client:
490
515
 
491
516
  ```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.3",
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",