@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 +32 -7
- package/dist/transports/http/index.d.ts +1 -0
- package/dist/transports/http/index.js +1 -0
- package/dist/transports/http/microservice.config.d.ts +3 -0
- package/dist/transports/http/microservice.config.js +16 -0
- package/dist/transports/index.d.ts +1 -0
- package/dist/transports/index.js +1 -0
- package/dist/transports/kafka/microservice.config.d.ts +2 -9
- package/dist/transports/microservice.options.d.ts +9 -0
- package/dist/transports/microservice.options.js +2 -0
- package/dist/transports/nats/index.d.ts +1 -0
- package/dist/transports/nats/index.js +1 -0
- package/dist/transports/nats/microservice.config.d.ts +3 -0
- package/dist/transports/nats/microservice.config.js +16 -0
- package/dist/transports/socket-io/index.d.ts +1 -0
- package/dist/transports/socket-io/index.js +1 -0
- package/dist/transports/socket-io/microservice.config.d.ts +3 -0
- package/dist/transports/socket-io/microservice.config.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,15 +114,14 @@ Start your service:
|
|
|
114
114
|
|
|
115
115
|
```typescript
|
|
116
116
|
// main.ts
|
|
117
|
-
import {
|
|
117
|
+
import { createNatsMicroservice } from "@riaskov/nevo-messaging"
|
|
118
118
|
import { AppModule } from "./app.module"
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
|
@@ -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,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
|
+
}
|
package/dist/transports/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { INestApplication
|
|
2
|
-
|
|
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>;
|
|
@@ -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,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
|
+
}
|
|
@@ -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,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