@lad-tech/nsc-toolkit 1.17.2 → 1.17.4
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 +2 -2
- package/dist/Client.js +1 -1
- package/dist/Service.js +12 -1
- package/dist/types/Service.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [1.17.
|
|
1
|
+
## [1.17.4](https://github.com/lad-tech/nsc-toolkit/compare/v1.17.3...v1.17.4) (2023-11-17)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Move nats debug log in debug level ([#91](https://github.com/lad-tech/nsc-toolkit/issues/91)) ([07e7688](https://github.com/lad-tech/nsc-toolkit/commit/07e7688a7332fb1cfa58ccb590357770d4bc77cf))
|
package/dist/Client.js
CHANGED
|
@@ -205,7 +205,7 @@ class Client extends Root_1.Root {
|
|
|
205
205
|
timeout,
|
|
206
206
|
}, async (response) => {
|
|
207
207
|
var _a;
|
|
208
|
-
if ((_a = options === null || options === void 0 ? void 0 : options.useStream) === null || _a === void 0 ? void 0 : _a.response) {
|
|
208
|
+
if (((_a = options === null || options === void 0 ? void 0 : options.useStream) === null || _a === void 0 ? void 0 : _a.response) && response.statusCode !== 500) {
|
|
209
209
|
resolve({ payload: response });
|
|
210
210
|
return;
|
|
211
211
|
}
|
package/dist/Service.js
CHANGED
|
@@ -228,9 +228,10 @@ class Service extends Root_1.Root {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
makeHttpSingleResponse(response, data) {
|
|
231
|
+
const isError = !data.payload && data.error && data.error.message;
|
|
231
232
|
const responseData = JSON.stringify(data);
|
|
232
233
|
response
|
|
233
|
-
.writeHead(200, {
|
|
234
|
+
.writeHead(isError ? 500 : 200, {
|
|
234
235
|
'Content-Length': Buffer.byteLength(responseData),
|
|
235
236
|
'Content-Type': 'application/json',
|
|
236
237
|
})
|
|
@@ -500,11 +501,21 @@ class Service extends Root_1.Root {
|
|
|
500
501
|
this.httpProbServer = undefined;
|
|
501
502
|
});
|
|
502
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Type guard for NATS debug event
|
|
506
|
+
*/
|
|
507
|
+
isNATSDebugEvent(event) {
|
|
508
|
+
return (event === nats_1.DebugEvents.PingTimer || event === nats_1.DebugEvents.Reconnecting || event === nats_1.DebugEvents.StaleConnection);
|
|
509
|
+
}
|
|
503
510
|
/**
|
|
504
511
|
* Logs events from the broker
|
|
505
512
|
*/
|
|
506
513
|
async watchBrokerEvents() {
|
|
507
514
|
for await (const event of this.broker.status()) {
|
|
515
|
+
if (this.isNATSDebugEvent(event.type)) {
|
|
516
|
+
this.logger.debug(`${event.type}: ${event.data}`);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
508
519
|
this.logger.warn(`${event.type}: ${event.data}`);
|
|
509
520
|
}
|
|
510
521
|
}
|
package/dist/types/Service.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export declare class Service<E extends Emitter = Emitter> extends Root {
|
|
|
98
98
|
* Up Probe Route for container orchestration service
|
|
99
99
|
*/
|
|
100
100
|
private upProbeRoutes;
|
|
101
|
+
/**
|
|
102
|
+
* Type guard for NATS debug event
|
|
103
|
+
*/
|
|
104
|
+
private isNATSDebugEvent;
|
|
101
105
|
/**
|
|
102
106
|
* Logs events from the broker
|
|
103
107
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lad-tech/nsc-toolkit",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"description": "Toolkit for create microservices around NATS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"typescript": "^5.1.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lad-tech/toolbelt": "^1.
|
|
37
|
+
"@lad-tech/toolbelt": "^1.3.1",
|
|
38
38
|
"@opentelemetry/api": "^1.1.0",
|
|
39
39
|
"@opentelemetry/exporter-jaeger": "^1.3.1",
|
|
40
40
|
"@opentelemetry/resources": "^1.3.1",
|