@rsdk/grpc.server 4.0.0-next.13 → 4.0.0-next.15
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/CHANGELOG.md +41 -15
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +5 -0
- package/dist/constants.js.map +1 -0
- package/dist/controllers/health.controller.js.map +1 -1
- package/dist/controllers/reflection/v1.base.controller.js.map +1 -1
- package/dist/grpc-errors.formatter.d.ts +1 -2
- package/dist/grpc-errors.formatter.js +2 -3
- package/dist/grpc-errors.formatter.js.map +1 -1
- package/dist/grpc-errors.sender.d.ts +1 -1
- package/dist/grpc-errors.sender.js +2 -3
- package/dist/grpc-errors.sender.js.map +1 -1
- package/dist/grpc-logger.interceptor.d.ts +3 -1
- package/dist/grpc-logger.interceptor.js +7 -3
- package/dist/grpc-logger.interceptor.js.map +1 -1
- package/dist/grpc.transport.d.ts +3 -2
- package/dist/grpc.transport.js +18 -7
- package/dist/grpc.transport.js.map +1 -1
- package/dist/reflection.service.js.map +1 -1
- package/jest.config.e2e.js +1 -0
- package/jest.config.js +1 -11
- package/jest.config.unit.js +1 -0
- package/package.json +9 -10
- package/src/constants.ts +1 -0
- package/src/grpc-errors.formatter.ts +2 -5
- package/src/grpc-errors.sender.ts +2 -3
- package/src/grpc-logger.interceptor.ts +5 -2
- package/src/grpc.transport.ts +27 -9
- package/tsconfig.json +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.0-next.15](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.14...v4.0.0-next.15) (2023-11-30)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added protocol detector ([#166](https://github.com/R-Vision/rsdk/issues/166)) ([f348995](https://github.com/R-Vision/rsdk/commit/f348995f29648c7392b7375c5b2001197d60eb36))
|
|
11
|
+
|
|
12
|
+
## [4.0.0-next.14](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.13...v4.0.0-next.14) (2023-11-29)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **core:** PFM-601 Add support send trace id from client to server ([#164](https://github.com/R-Vision/rsdk/issues/164)) ([9e37243](https://github.com/R-Vision/rsdk/commit/9e372437fbb3d7d2b1167b99d07b0ac64cb4013d)), closes [#pfm-601](https://github.com/R-Vision/rsdk/issues/pfm-601) [#pfm-601](https://github.com/R-Vision/rsdk/issues/pfm-601)
|
|
17
|
+
|
|
6
18
|
## [4.0.0-next.13](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.12...v4.0.0-next.13) (2023-11-29)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @rsdk/grpc.server
|
|
@@ -21,13 +33,15 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
21
33
|
|
|
22
34
|
### Features
|
|
23
35
|
|
|
24
|
-
* added configuration for request logging and move to trace level all request
|
|
36
|
+
* added configuration for request logging and move to trace level all request
|
|
37
|
+
logging ([#158](https://github.com/R-Vision/rsdk/issues/158)) ([0304672](https://github.com/R-Vision/rsdk/commit/0304672c112fd626642a2d44b0384fbf188e71b4))
|
|
25
38
|
|
|
26
39
|
## [3.7.0](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.5...v3.7.0) (2023-11-15)
|
|
27
40
|
|
|
28
41
|
### Features
|
|
29
42
|
|
|
30
|
-
* added logging to rpc and http
|
|
43
|
+
* added logging to rpc and http
|
|
44
|
+
transports ([#156](https://github.com/R-Vision/rsdk/issues/156)) ([7ebddb9](https://github.com/R-Vision/rsdk/commit/7ebddb97d2c30811eba9868b6d3ff9778708c957))
|
|
31
45
|
|
|
32
46
|
## [4.0.0-next.9](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.8...v4.0.0-next.9) (2023-11-29)
|
|
33
47
|
|
|
@@ -37,7 +51,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
37
51
|
|
|
38
52
|
### Features
|
|
39
53
|
|
|
40
|
-
* Kafka batch
|
|
54
|
+
* Kafka batch
|
|
55
|
+
producer ([#150](https://github.com/R-Vision/rsdk/issues/150)) ([2faa2f4](https://github.com/R-Vision/rsdk/commit/2faa2f41ca0dbb6d8a92cbf0ab20cf5cefeaf4e9))
|
|
41
56
|
|
|
42
57
|
## [4.0.0-next.7](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.6...v4.0.0-next.7) (2023-11-21)
|
|
43
58
|
|
|
@@ -51,7 +66,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
51
66
|
|
|
52
67
|
### Features
|
|
53
68
|
|
|
54
|
-
* **PFM-126:** reflection
|
|
69
|
+
* **PFM-126:** reflection
|
|
70
|
+
added ([ffaaa99](https://github.com/R-Vision/rsdk/commit/ffaaa996e0a81f98be46b0b73badb59f3e680eac))
|
|
55
71
|
|
|
56
72
|
### Bug Fixes
|
|
57
73
|
|
|
@@ -65,7 +81,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
65
81
|
|
|
66
82
|
### Bug Fixes
|
|
67
83
|
|
|
68
|
-
* all yarn peers dependency
|
|
84
|
+
* all yarn peers dependency
|
|
85
|
+
issues ([e0db9ef](https://github.com/R-Vision/rsdk/commit/e0db9ef1ab8a4df4e1f8ff6f6a9e3728f497549b))
|
|
69
86
|
|
|
70
87
|
## [4.0.0-next.2](https://github.com/R-Vision/rsdk/compare/v4.0.0-next.1...v4.0.0-next.2) (2023-11-10)
|
|
71
88
|
|
|
@@ -131,7 +148,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
131
148
|
|
|
132
149
|
### Features
|
|
133
150
|
|
|
134
|
-
* remove typeorm error
|
|
151
|
+
* remove typeorm error
|
|
152
|
+
hiding ([#126](https://github.com/R-Vision/rsdk/issues/126)) ([cef179b](https://github.com/R-Vision/rsdk/commit/cef179bfffcd2da72984f4a5a750f7ede5d8cfb7))
|
|
135
153
|
|
|
136
154
|
## [3.5.0-next.7](https://github.com/R-Vision/rsdk/compare/v3.5.0-next.6...v3.5.0-next.7) (2023-10-02)
|
|
137
155
|
|
|
@@ -205,7 +223,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
205
223
|
|
|
206
224
|
### Bug Fixes
|
|
207
225
|
|
|
208
|
-
* **grpc.server:** added message to `ClientError` in `cause` from mapped
|
|
226
|
+
* **grpc.server:** added message to `ClientError` in `cause` from mapped
|
|
227
|
+
errors ([da4ef10](https://github.com/R-Vision/rsdk/commit/da4ef10e21b7494791ba10a9068748ac0365a664))
|
|
209
228
|
|
|
210
229
|
## [3.3.0](https://github.com/R-Vision/rsdk/compare/v3.3.0-next.0...v3.3.0) (2023-08-10)
|
|
211
230
|
|
|
@@ -247,7 +266,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
247
266
|
|
|
248
267
|
### Features
|
|
249
268
|
|
|
250
|
-
* added exception code to
|
|
269
|
+
* added exception code to
|
|
270
|
+
payload ([#92](https://github.com/R-Vision/rsdk/issues/92)) ([6a9565b](https://github.com/R-Vision/rsdk/commit/6a9565b23746122676abb1f5166f9ef8b181864b))
|
|
251
271
|
|
|
252
272
|
## [3.0.2](https://github.com/R-Vision/rsdk/compare/v3.0.1...v3.0.2) (2023-08-07)
|
|
253
273
|
|
|
@@ -257,7 +277,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
257
277
|
|
|
258
278
|
### Bug Fixes
|
|
259
279
|
|
|
260
|
-
* **deps:** correctly
|
|
280
|
+
* **deps:** correctly
|
|
281
|
+
peerDependencies ([349628f](https://github.com/R-Vision/rsdk/commit/349628f10da46a30d6c8b9f9387e010869318212))
|
|
261
282
|
|
|
262
283
|
## [3.0.1-next.0](https://github.com/R-Vision/rsdk/compare/v3.0.0...v3.0.1-next.0) (2023-08-07)
|
|
263
284
|
|
|
@@ -283,7 +304,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
283
304
|
|
|
284
305
|
### Features
|
|
285
306
|
|
|
286
|
-
* **grpc.clients:** grpc rich
|
|
307
|
+
* **grpc.clients:** grpc rich
|
|
308
|
+
error ([#85](https://github.com/R-Vision/rsdk/issues/85)) ([be99f40](https://github.com/R-Vision/rsdk/commit/be99f408295bf1750f6f0c39e067cca971d973e3))
|
|
287
309
|
|
|
288
310
|
# [2.6.0-next.13](https://github.com/R-Vision/rsdk/compare/v2.6.0-next.12...v2.6.0-next.13) (2023-08-01)
|
|
289
311
|
|
|
@@ -385,12 +407,13 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
385
407
|
|
|
386
408
|
### Draft
|
|
387
409
|
|
|
388
|
-
* Pfm 303 static to meta
|
|
410
|
+
* Pfm 303 static to meta
|
|
411
|
+
migration ([#45](https://github.com/R-Vision/rsdk/issues/45)) ([d98e303](https://github.com/R-Vision/rsdk/commit/d98e3032f9b10446b478427d841b9209ed68fa2d))
|
|
389
412
|
|
|
390
413
|
### BREAKING CHANGES
|
|
391
414
|
|
|
392
415
|
* GrpcClientModule removed
|
|
393
|
-
new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
|
|
416
|
+
new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
|
|
394
417
|
|
|
395
418
|
* fix: rework interaction with metadata and generating modules from metadata
|
|
396
419
|
|
|
@@ -424,7 +447,8 @@ new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
|
|
|
424
447
|
|
|
425
448
|
### Bug Fixes
|
|
426
449
|
|
|
427
|
-
* remove private dependencies from `peerDependencies`
|
|
450
|
+
* remove private dependencies from `peerDependencies`
|
|
451
|
+
section ([0bce6ff](https://github.com/R-Vision/rsdk/commit/0bce6ffb5b699e2ed1dc9aca77cbdbf085267ff7))
|
|
428
452
|
|
|
429
453
|
## 1.0.11 (2023-05-23)
|
|
430
454
|
|
|
@@ -434,7 +458,8 @@ new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
|
|
|
434
458
|
|
|
435
459
|
### Bug Fixes
|
|
436
460
|
|
|
437
|
-
* add "access: public" to new
|
|
461
|
+
* add "access: public" to new
|
|
462
|
+
packages ([04d5983](https://github.com/R-Vision/rsdk/commit/04d5983cfa3e97c5d8219e07208a0499a8c6bc83))
|
|
438
463
|
|
|
439
464
|
## 1.0.9 (2023-05-21)
|
|
440
465
|
|
|
@@ -464,7 +489,8 @@ new way for declaration with `GrpcServers.define()` and `@InjectGrpcClient`
|
|
|
464
489
|
|
|
465
490
|
### Bug Fixes
|
|
466
491
|
|
|
467
|
-
* builtin make not private in
|
|
492
|
+
* builtin make not private in
|
|
493
|
+
npm ([50c83b6](https://github.com/R-Vision/rsdk/commit/50c83b6454f9a89f1e99d3b33a497ce2c029d8c6))
|
|
468
494
|
|
|
469
495
|
## 1.0.2 (2023-05-10)
|
|
470
496
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GRPC_PROTOCOL = "grpc";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../src/controllers/health.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+EAGoD;AAEpD,qCAIoB;AAKb,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEwB;IAChC;IAFnB,YACmD,MAAe,EAC/C,MAA2B;QADK,WAAM,GAAN,MAAM,CAAS;QAC/C,WAAM,GAAN,MAAM,CAAqB;IAC3C,CAAC;IAEJ;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAsB;QACzC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,iDAAgC,CAAC;QAElE,IAAI;
|
|
1
|
+
{"version":3,"file":"health.controller.js","sourceRoot":"","sources":["../../src/controllers/health.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,+EAGoD;AAEpD,qCAIoB;AAKb,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEwB;IAChC;IAFnB,YACmD,MAAe,EAC/C,MAA2B;QADK,WAAM,GAAN,MAAM,CAAS;QAC/C,WAAM,GAAN,MAAM,CAAqB;IAC3C,CAAC;IAEJ;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAsB;QACzC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,iDAAgC,CAAC;QAElE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAEjC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAkB,CAAC,CAAC;YAE5D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;IAED,KAAK;QACH,MAAM,IAAI,wBAAiB,CAAC,kCAAkC,CAAC,CAAC;IAClE,CAAC;CACF,CAAA;AAhCY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,kCAAiB,GAAE;IAGf,WAAA,IAAA,mBAAY,EAAC,gBAAgB,CAAC,CAAA;6CACN,0BAAmB;GAHnC,gBAAgB,CAgC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.base.controller.js","sourceRoot":"","sources":["../../../src/controllers/reflection/v1.base.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,2CAAiE;AAMjE,qCAA0C;AAG1C,+BAA+B;AAE/B,mDAA+C;AAC/C,iEAA6D;AAE7D;;;;;;;;GAQG;AACH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAItB;IACiC;IACN;IAH9C,YACmB,MAAkB,EACe,MAAe,EACrB,OAA0B;QAFrD,WAAM,GAAN,MAAM,CAAY;QACe,WAAM,GAAN,MAAM,CAAS;QACrB,YAAO,GAAP,OAAO,CAAmB;IACrE,CAAC;IAEJ;;;;;;OAMG;IACH,oBAAoB,CAClB,QAA6C;QAE7C,MAAM,SAAS,GAAG,IAAI,cAAO,EAA4B,CAAC;QAE1D,QAAQ,CAAC,SAAS,CAAC;YACjB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;gBAC1B,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC;gBACnC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC;YACxC,QAAQ,EAAE,GAAS,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE;SAC3C,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC,YAAY,EAAE,CAAC;IAClC,CAAC;IAEO,YAAY,CAClB,OAAgC;QAEhC,IAAI,OAAO,CAAC,cAAc,EAAE,KAAK,KAAK,cAAc,EAAE;
|
|
1
|
+
{"version":3,"file":"v1.base.controller.js","sourceRoot":"","sources":["../../../src/controllers/reflection/v1.base.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,2CAAiE;AAMjE,qCAA0C;AAG1C,+BAA+B;AAE/B,mDAA+C;AAC/C,iEAA6D;AAE7D;;;;;;;;GAQG;AACH,IAAa,8BAA8B,GAA3C,MAAa,8BAA8B;IAItB;IACiC;IACN;IAH9C,YACmB,MAAkB,EACe,MAAe,EACrB,OAA0B;QAFrD,WAAM,GAAN,MAAM,CAAY;QACe,WAAM,GAAN,MAAM,CAAS;QACrB,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B;GAN7D,8BAA8B,CAoJ1C"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ArgumentsHost } from '@nestjs/common';
|
|
2
1
|
import type { IErrorsFormatter } from '@rsdk/core';
|
|
3
2
|
import { ExceptionKind } from '@rsdk/core';
|
|
4
3
|
import type { FormattedGrpcError } from './types';
|
|
5
4
|
export declare class GrpcErrorsFormatter implements IErrorsFormatter {
|
|
6
5
|
static readonly defaultKind = ExceptionKind.UNKNOWN;
|
|
6
|
+
protocol: string;
|
|
7
7
|
private readonly statusMap;
|
|
8
|
-
match(host: ArgumentsHost): boolean;
|
|
9
8
|
format(ex: unknown, verboseErrors?: boolean): FormattedGrpcError;
|
|
10
9
|
}
|
|
@@ -26,8 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.GrpcErrorsFormatter = void 0;
|
|
27
27
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
28
28
|
const core_1 = require("@rsdk/core");
|
|
29
|
+
const constants_1 = require("./constants");
|
|
29
30
|
class GrpcErrorsFormatter {
|
|
30
31
|
static defaultKind = core_1.ExceptionKind.UNKNOWN;
|
|
32
|
+
protocol = constants_1.GRPC_PROTOCOL;
|
|
31
33
|
statusMap = {
|
|
32
34
|
[core_1.ExceptionKind.AUTHENTICATION]: grpc.status.UNAUTHENTICATED,
|
|
33
35
|
[core_1.ExceptionKind.NOT_ALLOWED]: grpc.status.PERMISSION_DENIED,
|
|
@@ -40,9 +42,6 @@ class GrpcErrorsFormatter {
|
|
|
40
42
|
[core_1.ExceptionKind.UNAVAILABLE]: grpc.status.UNAVAILABLE,
|
|
41
43
|
[core_1.ExceptionKind.UNKNOWN]: grpc.status.UNKNOWN,
|
|
42
44
|
};
|
|
43
|
-
match(host) {
|
|
44
|
-
return host.getType() === 'rpc';
|
|
45
|
-
}
|
|
46
45
|
format(ex, verboseErrors) {
|
|
47
46
|
if (ex instanceof core_1.PipelineException) {
|
|
48
47
|
const message = verboseErrors
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-errors.formatter.js","sourceRoot":"","sources":["../src/grpc-errors.formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;
|
|
1
|
+
{"version":3,"file":"grpc-errors.formatter.js","sourceRoot":"","sources":["../src/grpc-errors.formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,qCAA8D;AAE9D,2CAA4C;AAG5C,MAAa,mBAAmB;IAC9B,MAAM,CAAU,WAAW,GAAG,oBAAa,CAAC,OAAO,CAAC;IACpD,QAAQ,GAAG,yBAAa,CAAC;IACR,SAAS,GAAuC;QAC/D,CAAC,oBAAa,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;QAC3D,CAAC,oBAAa,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB;QAC1D,CAAC,oBAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB;QACzD,CAAC,oBAAa,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;QACnD,CAAC,oBAAa,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB;QACtD,CAAC,oBAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;QAC9C,CAAC,oBAAa,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;QACvD,CAAC,oBAAa,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;QAChD,CAAC,oBAAa,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;QACpD,CAAC,oBAAa,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;KAC7C,CAAC;IAEF,MAAM,CAAC,EAAW,EAAE,aAAuB;QACzC,IAAI,EAAE,YAAY,wBAAiB,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,aAAa;gBAC3B,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,wBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBACjE,CAAC,CAAC,oBAAa,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YAEtC,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC;gBAC7B,OAAO;gBACP,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBACxC,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,aAAa,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;aAClC,CAAC;QACJ,CAAC;QAED,MAAM,gBAAgB,GAAG,eAAe,CAAC;QAEzC,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,WAAW,CAAC;YACrD,OAAO,EAAE,aAAa;gBACpB,CAAC,CAAE,EAAU,EAAE,OAAO,IAAI,gBAAgB;gBAC1C,CAAC,CAAC,gBAAgB;YACpB,OAAO,EAAE,aAAa,CAAC,CAAC,CAAE,EAAU,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE;YAClD,IAAI,EAAG,EAAU,EAAE,IAAI,IAAI,mBAAmB,CAAC,WAAW;YAC1D,aAAa,EAAG,EAAU,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC7C,CAAC;IACJ,CAAC;;AA1CH,kDA2CC"}
|
|
@@ -3,6 +3,6 @@ import type { IErrorsSender } from '@rsdk/core';
|
|
|
3
3
|
import type { EMPTY, Observable } from 'rxjs';
|
|
4
4
|
import type { FormattedGrpcError } from './types';
|
|
5
5
|
export declare class GrpcErrorsSender implements IErrorsSender {
|
|
6
|
-
|
|
6
|
+
protocol: string;
|
|
7
7
|
send(_host: ArgumentsHost, ex: FormattedGrpcError): Observable<any> | typeof EMPTY;
|
|
8
8
|
}
|
|
@@ -7,10 +7,9 @@ const nice_grpc_1 = require("nice-grpc");
|
|
|
7
7
|
// @ts-ignore потому что не добавили в тайпинги...
|
|
8
8
|
const convertMetadata_1 = require("nice-grpc/lib/utils/convertMetadata");
|
|
9
9
|
const rxjs_1 = require("rxjs");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
10
11
|
class GrpcErrorsSender {
|
|
11
|
-
|
|
12
|
-
return host.getType() === 'rpc';
|
|
13
|
-
}
|
|
12
|
+
protocol = constants_1.GRPC_PROTOCOL;
|
|
14
13
|
send(_host, ex) {
|
|
15
14
|
const niceGrpcMetadata = (0, nice_grpc_1.Metadata)();
|
|
16
15
|
const status = grpc_error_v1_1.Status.fromPartial({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-errors.sender.js","sourceRoot":"","sources":["../src/grpc-errors.sender.ts"],"names":[],"mappings":";;;AACA,6EAAmE;AAEnE,yCAAyD;AACzD,6DAA6D;AAC7D,kDAAkD;AAClD,yEAA8E;AAE9E,+BAAkC;
|
|
1
|
+
{"version":3,"file":"grpc-errors.sender.js","sourceRoot":"","sources":["../src/grpc-errors.sender.ts"],"names":[],"mappings":";;;AACA,6EAAmE;AAEnE,yCAAyD;AACzD,6DAA6D;AAC7D,kDAAkD;AAClD,yEAA8E;AAE9E,+BAAkC;AAElC,2CAA4C;AAG5C,MAAa,gBAAgB;IAC3B,QAAQ,GAAG,yBAAa,CAAC;IAEzB,IAAI,CACF,KAAoB,EACpB,EAAsB;QAEtB,MAAM,gBAAgB,GAAG,IAAA,oBAAgB,GAAE,CAAC;QAE5C,MAAM,MAAM,GAAG,sBAAM,CAAC,WAAW,CAAC;YAChC,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,aAAa,EAAE,EAAE,CAAC,aAAa;SAChC,CAAC,CAAC;QAEH,gBAAgB,CAAC,GAAG,CAClB,yBAAyB,EACzB,sBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAC/B,CAAC;QACF,MAAM,KAAK,GAAG;YACZ,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,QAAQ,EAAE,IAAA,yCAAuB,EAAC,gBAAgB,CAAC;SACpD,CAAC;QAEF,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;CACF;AA5BD,4CA4BC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common/interfaces';
|
|
2
|
+
import { ProtocolDetector } from '@rsdk/core';
|
|
2
3
|
import { ILogger } from '@rsdk/logging';
|
|
3
4
|
import type { Observable } from 'rxjs';
|
|
4
5
|
import { GRPCConfig } from './grpc.config';
|
|
5
6
|
export declare class GrpcLoggerInterceptor implements NestInterceptor {
|
|
6
7
|
private logger;
|
|
7
8
|
private grpcConfig;
|
|
8
|
-
|
|
9
|
+
private detector;
|
|
10
|
+
constructor(logger: ILogger, grpcConfig: GRPCConfig, detector: ProtocolDetector);
|
|
9
11
|
intercept(context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
|
|
10
12
|
}
|
|
@@ -19,15 +19,18 @@ const grpc_config_1 = require("./grpc.config");
|
|
|
19
19
|
let GrpcLoggerInterceptor = class GrpcLoggerInterceptor {
|
|
20
20
|
logger;
|
|
21
21
|
grpcConfig;
|
|
22
|
-
|
|
22
|
+
detector;
|
|
23
|
+
constructor(logger, grpcConfig, detector) {
|
|
23
24
|
this.logger = logger;
|
|
24
25
|
this.grpcConfig = grpcConfig;
|
|
26
|
+
this.detector = detector;
|
|
25
27
|
}
|
|
26
28
|
intercept(context, next) {
|
|
27
29
|
if (!this.grpcConfig.requestLogging) {
|
|
28
30
|
return next.handle();
|
|
29
31
|
}
|
|
30
|
-
const
|
|
32
|
+
const protocol = this.detector.getProtocol(context);
|
|
33
|
+
const isRpc = protocol === 'grpc';
|
|
31
34
|
if (!isRpc) {
|
|
32
35
|
return next.handle();
|
|
33
36
|
}
|
|
@@ -68,6 +71,7 @@ let GrpcLoggerInterceptor = class GrpcLoggerInterceptor {
|
|
|
68
71
|
exports.GrpcLoggerInterceptor = GrpcLoggerInterceptor;
|
|
69
72
|
exports.GrpcLoggerInterceptor = GrpcLoggerInterceptor = __decorate([
|
|
70
73
|
__param(0, (0, core_1.InjectLogger)(GrpcLoggerInterceptor)),
|
|
71
|
-
__metadata("design:paramtypes", [Object, grpc_config_1.GRPCConfig
|
|
74
|
+
__metadata("design:paramtypes", [Object, grpc_config_1.GRPCConfig,
|
|
75
|
+
core_1.ProtocolDetector])
|
|
72
76
|
], GrpcLoggerInterceptor);
|
|
73
77
|
//# sourceMappingURL=grpc-logger.interceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-logger.interceptor.js","sourceRoot":"","sources":["../src/grpc-logger.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,
|
|
1
|
+
{"version":3,"file":"grpc-logger.interceptor.js","sourceRoot":"","sources":["../src/grpc-logger.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,qCAA4D;AAG5D,+BAAmD;AAEnD,+CAA2C;AAE3C,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAEe;IACrC;IACA;IAHV,YAC+C,MAAe,EACpD,UAAsB,EACtB,QAA0B;QAFW,WAAM,GAAN,MAAM,CAAS;QACpD,eAAU,GAAV,UAAU,CAAY;QACtB,aAAQ,GAAR,QAAQ,CAAkB;IACjC,CAAC;IAEJ,SAAS,CACP,OAAyB,EACzB,IAAsB;QA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,QAAQ,EAAE,EAAE;YACf,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE;gBACvC,OAAO,EAAE,aAAa;gBACtB,SAAS;gBACT,OAAO;gBACP,QAAQ,EAAE,OAAO,GAAG,SAAS;gBAC7B,QAAQ;aACT,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AA9DY,sDAAqB;gCAArB,qBAAqB;IAE7B,WAAA,IAAA,mBAAY,EAAC,qBAAqB,CAAC,CAAA;6CAChB,wBAAU;QACZ,uBAAgB;GAJzB,qBAAqB,CA8DjC"}
|
package/dist/grpc.transport.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type { Controller } from '@nestjs/common/interfaces';
|
|
1
|
+
import type { Controller, ExecutionContext } from '@nestjs/common/interfaces';
|
|
2
2
|
import type { MicroserviceOptions } from '@nestjs/microservices';
|
|
3
3
|
import type { Constructor } from '@rsdk/common';
|
|
4
4
|
import type { ConfigContext, IErrorsFormatter, IErrorsSender, IErrorsTransformer, IMicroserviceTransport, NestModuleDefinitions } from '@rsdk/core';
|
|
5
5
|
import type { Package } from '@rsdk/grpc.loader';
|
|
6
6
|
export declare class GrpcTransport implements IMicroserviceTransport {
|
|
7
|
-
private readonly systemPackages;
|
|
8
7
|
private readonly logger;
|
|
9
8
|
private readonly packages;
|
|
10
9
|
private address?;
|
|
11
10
|
private maxRecv?;
|
|
12
11
|
private maxSend?;
|
|
13
12
|
private isInitialized;
|
|
13
|
+
private readonly systemPackages;
|
|
14
14
|
constructor(...packages: Package[]);
|
|
15
|
+
matchByContext(ctx: ExecutionContext): boolean;
|
|
15
16
|
getProtocol(): string;
|
|
16
17
|
getErrorsFormatter(): IErrorsFormatter;
|
|
17
18
|
getErrorsSender(): IErrorsSender;
|
package/dist/grpc.transport.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GrpcTransport = void 0;
|
|
7
|
+
const server_call_1 = require("@grpc/grpc-js/build/src/server-call");
|
|
7
8
|
const core_1 = require("@nestjs/core");
|
|
8
9
|
const grpc_health_v1_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.health.v1"));
|
|
9
10
|
const grpc_metrics_v1_1 = __importDefault(require("@rsdk/builtin-contract/dist/grpc.metrics.v1"));
|
|
@@ -12,6 +13,7 @@ const grpc_reflection_v1alpha_1 = __importDefault(require("@rsdk/builtin-contrac
|
|
|
12
13
|
const core_2 = require("@rsdk/core");
|
|
13
14
|
const grpc_loader_1 = require("@rsdk/grpc.loader");
|
|
14
15
|
const logging_1 = require("@rsdk/logging");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
15
17
|
const controllers_1 = require("./controllers");
|
|
16
18
|
const grpc_config_1 = require("./grpc.config");
|
|
17
19
|
const grpc_utils_1 = require("./grpc.utils");
|
|
@@ -20,23 +22,32 @@ const grpc_errors_sender_1 = require("./grpc-errors.sender");
|
|
|
20
22
|
const grpc_logger_interceptor_1 = require("./grpc-logger.interceptor");
|
|
21
23
|
const reflection_module_1 = require("./reflection.module");
|
|
22
24
|
class GrpcTransport {
|
|
23
|
-
systemPackages = [
|
|
24
|
-
grpc_health_v1_1.default,
|
|
25
|
-
grpc_metrics_v1_1.default,
|
|
26
|
-
grpc_reflection_v1_1.default,
|
|
27
|
-
grpc_reflection_v1alpha_1.default,
|
|
28
|
-
];
|
|
29
25
|
logger = logging_1.LoggerFactory.create(GrpcTransport);
|
|
30
26
|
packages;
|
|
31
27
|
address;
|
|
32
28
|
maxRecv;
|
|
33
29
|
maxSend;
|
|
34
30
|
isInitialized = false;
|
|
31
|
+
systemPackages = [
|
|
32
|
+
grpc_health_v1_1.default,
|
|
33
|
+
grpc_metrics_v1_1.default,
|
|
34
|
+
grpc_reflection_v1_1.default,
|
|
35
|
+
grpc_reflection_v1alpha_1.default,
|
|
36
|
+
];
|
|
35
37
|
constructor(...packages) {
|
|
36
38
|
this.packages = packages;
|
|
37
39
|
}
|
|
40
|
+
matchByContext(ctx) {
|
|
41
|
+
const call = ctx.getArgByIndex(2);
|
|
42
|
+
const isGrpc = [
|
|
43
|
+
server_call_1.ServerUnaryCallImpl,
|
|
44
|
+
server_call_1.ServerDuplexStreamImpl,
|
|
45
|
+
server_call_1.ServerWritableStreamImpl,
|
|
46
|
+
].some((impl) => call instanceof impl);
|
|
47
|
+
return isGrpc;
|
|
48
|
+
}
|
|
38
49
|
getProtocol() {
|
|
39
|
-
return
|
|
50
|
+
return constants_1.GRPC_PROTOCOL;
|
|
40
51
|
}
|
|
41
52
|
getErrorsFormatter() {
|
|
42
53
|
return new grpc_errors_formatter_1.GrpcErrorsFormatter();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.transport.js","sourceRoot":"","sources":["../src/grpc.transport.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"grpc.transport.js","sourceRoot":"","sources":["../src/grpc.transport.ts"],"names":[],"mappings":";;;;;;AAAA,qEAI6C;AAE7C,uCAA+C;AAE/C,gGAA2E;AAC3E,kGAA6E;AAC7E,wGAAqF;AACrF,kHAA+F;AAU/F,qCAA+C;AAE/C,mDAAsD;AACtD,2CAA8C;AAE9C,2CAA4C;AAC5C,+CAAoE;AACpE,+CAA2C;AAC3C,6CAAoD;AACpD,mEAA8D;AAC9D,6DAAwD;AACxD,uEAAkE;AAClE,2DAAuD;AAEvD,MAAa,aAAa;IACP,MAAM,GAAG,uBAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7C,QAAQ,CAAY;IAE7B,OAAO,CAAU;IACjB,OAAO,CAAU;IACjB,OAAO,CAAU;IAEjB,aAAa,GAAG,KAAK,CAAC;IAEb,cAAc,GAAc;QAC3C,wBAAiB;QACjB,y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C;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AA7LY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAME,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;;GALzB,iBAAiB,CA6L7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config.e2e');
|
package/jest.config.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const { resolve } = require('node:path');
|
|
3
|
-
|
|
4
|
-
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
5
|
-
module.exports = {
|
|
6
|
-
preset: 'ts-jest',
|
|
7
|
-
testEnvironment: 'node',
|
|
8
|
-
|
|
9
|
-
setupFiles: ['dotenv/config'],
|
|
10
|
-
rootDir: resolve(__dirname, 'src'),
|
|
11
|
-
};
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@rsdk/jest/jest.config.unit');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/grpc.server",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.15",
|
|
4
4
|
"description": "Grpc transport for platform, clients and common grpc stuff",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,19 +18,18 @@
|
|
|
18
18
|
"@nestjs/common": "^10.0.0",
|
|
19
19
|
"@nestjs/core": "^10.0.0",
|
|
20
20
|
"@nestjs/microservices": "^10.0.0",
|
|
21
|
-
"@rsdk/builtin-contract": "^4.0.0-next.
|
|
22
|
-
"@rsdk/common": "^4.0.0-next.
|
|
23
|
-
"@rsdk/core": "^4.0.0-next.
|
|
24
|
-
"@rsdk/grpc.common": "^4.0.0-next.
|
|
25
|
-
"@rsdk/grpc.loader": "^4.0.0-next.
|
|
26
|
-
"@rsdk/logging": "^4.0.0-next.
|
|
21
|
+
"@rsdk/builtin-contract": "^4.0.0-next.15",
|
|
22
|
+
"@rsdk/common": "^4.0.0-next.15",
|
|
23
|
+
"@rsdk/core": "^4.0.0-next.15",
|
|
24
|
+
"@rsdk/grpc.common": "^4.0.0-next.15",
|
|
25
|
+
"@rsdk/grpc.loader": "^4.0.0-next.15",
|
|
26
|
+
"@rsdk/logging": "^4.0.0-next.15",
|
|
27
27
|
"nice-grpc": "^2.1.4",
|
|
28
28
|
"reflect-metadata": "^0.1.13",
|
|
29
29
|
"rxjs": "^7.8.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@bufbuild/protobuf": "^1.4.2"
|
|
33
|
-
"nice-grpc-opentelemetry": "^0.1.2"
|
|
32
|
+
"@bufbuild/protobuf": "^1.4.2"
|
|
34
33
|
},
|
|
35
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "8abd89d7800375749b024410dc3465ff40389277"
|
|
36
35
|
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GRPC_PROTOCOL = 'grpc';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import type { ArgumentsHost } from '@nestjs/common';
|
|
3
2
|
import type { IErrorsFormatter } from '@rsdk/core';
|
|
4
3
|
import { ExceptionKind, PipelineException } from '@rsdk/core';
|
|
5
4
|
|
|
5
|
+
import { GRPC_PROTOCOL } from './constants';
|
|
6
6
|
import type { FormattedGrpcError } from './types';
|
|
7
7
|
|
|
8
8
|
export class GrpcErrorsFormatter implements IErrorsFormatter {
|
|
9
9
|
static readonly defaultKind = ExceptionKind.UNKNOWN;
|
|
10
|
+
protocol = GRPC_PROTOCOL;
|
|
10
11
|
private readonly statusMap: Record<ExceptionKind, grpc.status> = {
|
|
11
12
|
[ExceptionKind.AUTHENTICATION]: grpc.status.UNAUTHENTICATED,
|
|
12
13
|
[ExceptionKind.NOT_ALLOWED]: grpc.status.PERMISSION_DENIED,
|
|
@@ -20,10 +21,6 @@ export class GrpcErrorsFormatter implements IErrorsFormatter {
|
|
|
20
21
|
[ExceptionKind.UNKNOWN]: grpc.status.UNKNOWN,
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
match(host: ArgumentsHost): boolean {
|
|
24
|
-
return host.getType() === 'rpc';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
24
|
format(ex: unknown, verboseErrors?: boolean): FormattedGrpcError {
|
|
28
25
|
if (ex instanceof PipelineException) {
|
|
29
26
|
const message = verboseErrors
|
|
@@ -8,12 +8,11 @@ import { convertMetadataToGrpcJs } from 'nice-grpc/lib/utils/convertMetadata';
|
|
|
8
8
|
import type { EMPTY, Observable } from 'rxjs';
|
|
9
9
|
import { throwError } from 'rxjs';
|
|
10
10
|
|
|
11
|
+
import { GRPC_PROTOCOL } from './constants';
|
|
11
12
|
import type { FormattedGrpcError } from './types';
|
|
12
13
|
|
|
13
14
|
export class GrpcErrorsSender implements IErrorsSender {
|
|
14
|
-
|
|
15
|
-
return host.getType() === 'rpc';
|
|
16
|
-
}
|
|
15
|
+
protocol = GRPC_PROTOCOL;
|
|
17
16
|
|
|
18
17
|
send(
|
|
19
18
|
_host: ArgumentsHost,
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
ExecutionContext,
|
|
4
4
|
NestInterceptor,
|
|
5
5
|
} from '@nestjs/common/interfaces';
|
|
6
|
-
import { InjectLogger } from '@rsdk/core';
|
|
6
|
+
import { InjectLogger, ProtocolDetector } from '@rsdk/core';
|
|
7
7
|
import { ILogger } from '@rsdk/logging';
|
|
8
8
|
import type { Observable } from 'rxjs';
|
|
9
9
|
import { catchError, tap, throwError } from 'rxjs';
|
|
@@ -14,6 +14,7 @@ export class GrpcLoggerInterceptor implements NestInterceptor {
|
|
|
14
14
|
constructor(
|
|
15
15
|
@InjectLogger(GrpcLoggerInterceptor) private logger: ILogger,
|
|
16
16
|
private grpcConfig: GRPCConfig,
|
|
17
|
+
private detector: ProtocolDetector,
|
|
17
18
|
) {}
|
|
18
19
|
|
|
19
20
|
intercept(
|
|
@@ -23,7 +24,9 @@ export class GrpcLoggerInterceptor implements NestInterceptor {
|
|
|
23
24
|
if (!this.grpcConfig.requestLogging) {
|
|
24
25
|
return next.handle();
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
const protocol = this.detector.getProtocol(context);
|
|
29
|
+
const isRpc = protocol === 'grpc';
|
|
27
30
|
if (!isRpc) {
|
|
28
31
|
return next.handle();
|
|
29
32
|
}
|
package/src/grpc.transport.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
ServerDuplexStreamImpl,
|
|
3
|
+
ServerUnaryCallImpl,
|
|
4
|
+
ServerWritableStreamImpl,
|
|
5
|
+
} from '@grpc/grpc-js/build/src/server-call';
|
|
6
|
+
import type { Controller, ExecutionContext } from '@nestjs/common/interfaces';
|
|
2
7
|
import { APP_INTERCEPTOR } from '@nestjs/core';
|
|
3
8
|
import type { MicroserviceOptions } from '@nestjs/microservices';
|
|
4
9
|
import HealthGrpcPackage from '@rsdk/builtin-contract/dist/grpc.health.v1';
|
|
@@ -19,6 +24,7 @@ import type { Package } from '@rsdk/grpc.loader';
|
|
|
19
24
|
import { createGrpcOptions } from '@rsdk/grpc.loader';
|
|
20
25
|
import { LoggerFactory } from '@rsdk/logging';
|
|
21
26
|
|
|
27
|
+
import { GRPC_PROTOCOL } from './constants';
|
|
22
28
|
import { HealthController, MetricsController } from './controllers';
|
|
23
29
|
import { GRPCConfig } from './grpc.config';
|
|
24
30
|
import { isPackageNotIncluded } from './grpc.utils';
|
|
@@ -28,13 +34,6 @@ import { GrpcLoggerInterceptor } from './grpc-logger.interceptor';
|
|
|
28
34
|
import { ReflectionModule } from './reflection.module';
|
|
29
35
|
|
|
30
36
|
export class GrpcTransport implements IMicroserviceTransport {
|
|
31
|
-
private readonly systemPackages: Package[] = [
|
|
32
|
-
HealthGrpcPackage,
|
|
33
|
-
MetricsGrpcPackage,
|
|
34
|
-
ReflectionGrpcPackageV1,
|
|
35
|
-
ReflectionGrpcPackageV1alpha,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
37
|
private readonly logger = LoggerFactory.create(GrpcTransport);
|
|
39
38
|
private readonly packages: Package[];
|
|
40
39
|
|
|
@@ -44,12 +43,31 @@ export class GrpcTransport implements IMicroserviceTransport {
|
|
|
44
43
|
|
|
45
44
|
private isInitialized = false;
|
|
46
45
|
|
|
46
|
+
private readonly systemPackages: Package[] = [
|
|
47
|
+
HealthGrpcPackage,
|
|
48
|
+
MetricsGrpcPackage,
|
|
49
|
+
ReflectionGrpcPackageV1,
|
|
50
|
+
ReflectionGrpcPackageV1alpha,
|
|
51
|
+
];
|
|
52
|
+
|
|
47
53
|
constructor(...packages: Package[]) {
|
|
48
54
|
this.packages = packages;
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
matchByContext(ctx: ExecutionContext): boolean {
|
|
58
|
+
const call = ctx.getArgByIndex(2);
|
|
59
|
+
|
|
60
|
+
const isGrpc = [
|
|
61
|
+
ServerUnaryCallImpl,
|
|
62
|
+
ServerDuplexStreamImpl,
|
|
63
|
+
ServerWritableStreamImpl,
|
|
64
|
+
].some((impl) => call instanceof impl);
|
|
65
|
+
|
|
66
|
+
return isGrpc;
|
|
67
|
+
}
|
|
68
|
+
|
|
51
69
|
getProtocol(): string {
|
|
52
|
-
return
|
|
70
|
+
return GRPC_PROTOCOL;
|
|
53
71
|
}
|
|
54
72
|
|
|
55
73
|
getErrorsFormatter(): IErrorsFormatter {
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
2
|
"extends": "@rsdk/tsconfig/base.json",
|
|
4
3
|
"compilerOptions": {
|
|
5
4
|
"declaration": true,
|
|
6
5
|
"outDir": "dist"
|
|
7
6
|
},
|
|
8
|
-
"include": [
|
|
9
|
-
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*"
|
|
9
|
+
],
|
|
10
|
+
"exclude": [
|
|
11
|
+
"node_modules",
|
|
12
|
+
"dist",
|
|
13
|
+
"test",
|
|
14
|
+
"**/*.spec.ts",
|
|
15
|
+
"**/*.test.ts",
|
|
16
|
+
"**/*.spec.e2e.ts",
|
|
17
|
+
"**/*.test.e2e.ts"
|
|
18
|
+
]
|
|
10
19
|
}
|