@ngn-net/nestjs-telescope 0.2.7 → 0.2.9
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/dist/ui/manifest.json
CHANGED
|
@@ -22,6 +22,10 @@ let ExceptionWatcher = class ExceptionWatcher {
|
|
|
22
22
|
this.telescope = telescope;
|
|
23
23
|
}
|
|
24
24
|
intercept(context, next) {
|
|
25
|
+
// Skip non-HTTP execution contexts (e.g. RPC/RabbitMQ or WebSockets)
|
|
26
|
+
if (context.getType() !== 'http') {
|
|
27
|
+
return next.handle();
|
|
28
|
+
}
|
|
25
29
|
const request = context.switchToHttp().getRequest();
|
|
26
30
|
return next.handle().pipe((0, operators_1.catchError)((err) => {
|
|
27
31
|
this.telescope.record({
|
|
@@ -38,7 +42,7 @@ let ExceptionWatcher = class ExceptionWatcher {
|
|
|
38
42
|
ip: request?.ip,
|
|
39
43
|
},
|
|
40
44
|
},
|
|
41
|
-
});
|
|
45
|
+
}).catch(() => { });
|
|
42
46
|
return (0, rxjs_1.throwError)(() => err);
|
|
43
47
|
}));
|
|
44
48
|
}
|
|
@@ -27,6 +27,10 @@ let HttpRequestWatcher = class HttpRequestWatcher {
|
|
|
27
27
|
this.options = options;
|
|
28
28
|
}
|
|
29
29
|
intercept(context, next) {
|
|
30
|
+
// Skip non-HTTP execution contexts (e.g. RPC/RabbitMQ or WebSockets)
|
|
31
|
+
if (context.getType() !== 'http') {
|
|
32
|
+
return next.handle();
|
|
33
|
+
}
|
|
30
34
|
const request = context.switchToHttp().getRequest();
|
|
31
35
|
const response = context.switchToHttp().getResponse();
|
|
32
36
|
const url = request.originalUrl || request.url || '/';
|
|
@@ -43,20 +47,40 @@ let HttpRequestWatcher = class HttpRequestWatcher {
|
|
|
43
47
|
query: request.query,
|
|
44
48
|
ip: request.ip,
|
|
45
49
|
};
|
|
46
|
-
return next.handle().pipe((0, operators_1.tap)(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
return next.handle().pipe((0, operators_1.tap)({
|
|
51
|
+
next: (responseBody) => {
|
|
52
|
+
const duration = Date.now() - start;
|
|
53
|
+
const statusCode = response.statusCode || 200;
|
|
54
|
+
this.telescope.record({
|
|
55
|
+
type: entry_type_enum_1.EntryType.REQUEST,
|
|
56
|
+
content: {
|
|
57
|
+
request: requestData,
|
|
58
|
+
response: {
|
|
59
|
+
statusCode,
|
|
60
|
+
body: responseBody,
|
|
61
|
+
},
|
|
62
|
+
duration,
|
|
63
|
+
},
|
|
64
|
+
}).catch(() => { });
|
|
65
|
+
},
|
|
66
|
+
error: (error) => {
|
|
67
|
+
const duration = Date.now() - start;
|
|
68
|
+
const statusCode = error.status || error.statusCode || 500;
|
|
69
|
+
this.telescope.record({
|
|
70
|
+
type: entry_type_enum_1.EntryType.REQUEST,
|
|
71
|
+
content: {
|
|
72
|
+
request: requestData,
|
|
73
|
+
response: {
|
|
74
|
+
statusCode,
|
|
75
|
+
body: {
|
|
76
|
+
message: error.message || String(error),
|
|
77
|
+
error: error.name || 'Error',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
duration,
|
|
56
81
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
82
|
+
}).catch(() => { });
|
|
83
|
+
},
|
|
60
84
|
}));
|
|
61
85
|
}
|
|
62
86
|
};
|
|
@@ -11,6 +11,7 @@ export declare class ModelSubscriber implements EntitySubscriberInterface, OnMod
|
|
|
11
11
|
constructor(telescope: TelescopeService, dataSource?: DataSource | undefined);
|
|
12
12
|
onModuleInit(): void;
|
|
13
13
|
listenTo(): ObjectConstructor;
|
|
14
|
+
private isTelescopeEntity;
|
|
14
15
|
afterInsert(event: InsertEvent<any>): void;
|
|
15
16
|
afterUpdate(event: UpdateEvent<any>): void;
|
|
16
17
|
afterRemove(event: RemoveEvent<any>): void;
|
|
@@ -46,7 +46,14 @@ let ModelSubscriber = ModelSubscriber_1 = class ModelSubscriber {
|
|
|
46
46
|
// Listen to all entities
|
|
47
47
|
return Object;
|
|
48
48
|
}
|
|
49
|
+
isTelescopeEntity(event) {
|
|
50
|
+
const name = event.metadata?.name;
|
|
51
|
+
const tableName = event.metadata?.tableName;
|
|
52
|
+
return name === 'TelescopeEntry' || tableName === 'telescope_entries';
|
|
53
|
+
}
|
|
49
54
|
afterInsert(event) {
|
|
55
|
+
if (this.isTelescopeEntity(event))
|
|
56
|
+
return;
|
|
50
57
|
this.telescope.record({
|
|
51
58
|
type: entry_type_enum_1.EntryType.MODEL,
|
|
52
59
|
content: {
|
|
@@ -58,6 +65,8 @@ let ModelSubscriber = ModelSubscriber_1 = class ModelSubscriber {
|
|
|
58
65
|
}).catch(() => { });
|
|
59
66
|
}
|
|
60
67
|
afterUpdate(event) {
|
|
68
|
+
if (this.isTelescopeEntity(event))
|
|
69
|
+
return;
|
|
61
70
|
this.telescope.record({
|
|
62
71
|
type: entry_type_enum_1.EntryType.MODEL,
|
|
63
72
|
content: {
|
|
@@ -70,6 +79,8 @@ let ModelSubscriber = ModelSubscriber_1 = class ModelSubscriber {
|
|
|
70
79
|
}).catch(() => { });
|
|
71
80
|
}
|
|
72
81
|
afterRemove(event) {
|
|
82
|
+
if (this.isTelescopeEntity(event))
|
|
83
|
+
return;
|
|
73
84
|
this.telescope.record({
|
|
74
85
|
type: entry_type_enum_1.EntryType.MODEL,
|
|
75
86
|
content: {
|