@nmxjs/api 1.2.15 → 1.2.16
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.
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { NestInterceptor, CallHandler, ExecutionContext } from '@nestjs/common';
|
|
3
3
|
import type { INotifier } from '@nmxjs/notifications';
|
|
4
4
|
export declare class RpcExceptionInterceptor implements NestInterceptor {
|
|
5
|
+
protected readonly serviceName: string;
|
|
5
6
|
protected readonly debug: boolean;
|
|
6
7
|
protected readonly notifier?: INotifier;
|
|
7
|
-
constructor(debug?: boolean, notifier?: INotifier);
|
|
8
|
+
constructor(serviceName: string, debug?: boolean, notifier?: INotifier);
|
|
8
9
|
intercept(context: ExecutionContext, next: CallHandler): any;
|
|
9
10
|
}
|
|
@@ -16,14 +16,15 @@ const utils_1 = require("@nmxjs/utils");
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const constants_1 = require("../constants");
|
|
18
18
|
let RpcExceptionInterceptor = class RpcExceptionInterceptor {
|
|
19
|
-
constructor(debug = false, notifier) {
|
|
19
|
+
constructor(serviceName, debug = false, notifier) {
|
|
20
|
+
this.serviceName = serviceName;
|
|
20
21
|
this.debug = debug;
|
|
21
22
|
this.notifier = notifier;
|
|
22
23
|
}
|
|
23
24
|
intercept(context, next) {
|
|
24
|
-
var _a, _b, _c;
|
|
25
|
+
var _a, _b, _c, _d;
|
|
25
26
|
const requestId = (0, utils_1.uuid)();
|
|
26
|
-
const path = (
|
|
27
|
+
const path = ((_a = context.getArgByIndex(2)) === null || _a === void 0 ? void 0 : _a.path) || ((_d = (_c = (_b = context.getArgByIndex(2)) === null || _b === void 0 ? void 0 : _b.call) === null || _c === void 0 ? void 0 : _c.handler) === null || _d === void 0 ? void 0 : _d.path);
|
|
27
28
|
if (this.debug) {
|
|
28
29
|
common_1.Logger.debug(`Rpc Request: ${(0, utils_1.readableJson)(Object.assign({ requestId, data: context.getArgByIndex(0) }, (path ? { path } : { event: context.getArgByIndex(1).args[0] })))}`);
|
|
29
30
|
}
|
|
@@ -47,7 +48,13 @@ let RpcExceptionInterceptor = class RpcExceptionInterceptor {
|
|
|
47
48
|
}
|
|
48
49
|
common_1.Logger.error(errorMessage);
|
|
49
50
|
if (this.notifier && !e.silent) {
|
|
50
|
-
this.notifier.sendError({
|
|
51
|
+
this.notifier.sendError({
|
|
52
|
+
message: errorMessage.split('\n at')[0],
|
|
53
|
+
code: e.code || 'UNKNOWN RPC',
|
|
54
|
+
path,
|
|
55
|
+
serviceName: this.serviceName,
|
|
56
|
+
params: context.getArgByIndex(0),
|
|
57
|
+
});
|
|
51
58
|
}
|
|
52
59
|
throw new microservices_1.RpcException(`${errorMessage}${constants_1.endErrorText}`);
|
|
53
60
|
}));
|
|
@@ -56,6 +63,6 @@ let RpcExceptionInterceptor = class RpcExceptionInterceptor {
|
|
|
56
63
|
exports.RpcExceptionInterceptor = RpcExceptionInterceptor;
|
|
57
64
|
exports.RpcExceptionInterceptor = RpcExceptionInterceptor = __decorate([
|
|
58
65
|
(0, common_1.Injectable)(),
|
|
59
|
-
__metadata("design:paramtypes", [Boolean, Object])
|
|
66
|
+
__metadata("design:paramtypes", [String, Boolean, Object])
|
|
60
67
|
], RpcExceptionInterceptor);
|
|
61
68
|
//# sourceMappingURL=RpcExceptionInterceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RpcExceptionInterceptor.js","sourceRoot":"","sources":["../../../src/ApiRouterCore/utils/RpcExceptionInterceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAuC;AACvC,yDAAqD;AACrD,wCAAkD;AAClD,2CAAoG;AACpG,4CAA4C;AAIrC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC,YAA+B,QAAiB,KAAK,EAAqB,QAAoB;
|
|
1
|
+
{"version":3,"file":"RpcExceptionInterceptor.js","sourceRoot":"","sources":["../../../src/ApiRouterCore/utils/RpcEx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
|
}
|
|
73
73
|
declare module '@nmxjs/notifications' {
|
|
74
|
+
interface INotificationSendErrorOptions {
|
|
75
|
+
message: string;
|
|
76
|
+
code: string;
|
|
77
|
+
params?: Record<string, unknown>;
|
|
78
|
+
serviceName?: string;
|
|
79
|
+
path?: string;
|
|
80
|
+
}
|
|
74
81
|
interface INotifier {
|
|
75
|
-
sendError(error:
|
|
82
|
+
sendError(error: INotificationSendErrorOptions): void;
|
|
76
83
|
}
|
|
77
84
|
}
|