@biorate/nestjs-tools 2.6.0 → 2.7.0
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.
|
@@ -25,9 +25,7 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
25
25
|
const response = ctx.getResponse();
|
|
26
26
|
const request = ctx.getRequest();
|
|
27
27
|
const meta = this.exception?.meta;
|
|
28
|
-
const status = this.
|
|
29
|
-
? this.exception.getStatus()
|
|
30
|
-
: meta?.status ?? common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
28
|
+
const status = this.httpStatus;
|
|
31
29
|
this.log(this.exception);
|
|
32
30
|
response.status(status).json(this.format({
|
|
33
31
|
status,
|
|
@@ -39,12 +37,11 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
39
37
|
const ctx = this.host.switchToWs();
|
|
40
38
|
const socket = ctx.getClient();
|
|
41
39
|
const meta = this.exception?.meta;
|
|
42
|
-
const status = meta?.status ?? common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
43
40
|
this.log(this.exception);
|
|
44
41
|
socket.send(JSON.stringify({
|
|
45
42
|
event: 'error',
|
|
46
43
|
data: this.format({
|
|
47
|
-
status,
|
|
44
|
+
status: this.wsStatus,
|
|
48
45
|
meta: meta?.meta,
|
|
49
46
|
}),
|
|
50
47
|
}));
|
|
@@ -58,6 +55,14 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
58
55
|
hint(exception) {
|
|
59
56
|
return (exception?.getResponse?.()?.message ?? exception.message);
|
|
60
57
|
}
|
|
58
|
+
get httpStatus() {
|
|
59
|
+
return this.exception instanceof common_1.HttpException
|
|
60
|
+
? this.exception.getStatus()
|
|
61
|
+
: this.exception?.meta?.status ?? common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
62
|
+
}
|
|
63
|
+
get wsStatus() {
|
|
64
|
+
return this.exception?.meta?.status ?? common_1.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
65
|
+
}
|
|
61
66
|
format(data) {
|
|
62
67
|
return {
|
|
63
68
|
code: this.code(this.exception),
|
|
@@ -22,9 +22,7 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
22
22
|
const response = ctx.getResponse();
|
|
23
23
|
const request = ctx.getRequest();
|
|
24
24
|
const meta = this.exception?.meta;
|
|
25
|
-
const status = this.
|
|
26
|
-
? this.exception.getStatus()
|
|
27
|
-
: meta?.status ?? HttpStatus.INTERNAL_SERVER_ERROR;
|
|
25
|
+
const status = this.httpStatus;
|
|
28
26
|
this.log(this.exception);
|
|
29
27
|
response.status(status).json(this.format({
|
|
30
28
|
status,
|
|
@@ -36,12 +34,11 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
36
34
|
const ctx = this.host.switchToWs();
|
|
37
35
|
const socket = ctx.getClient();
|
|
38
36
|
const meta = this.exception?.meta;
|
|
39
|
-
const status = meta?.status ?? HttpStatus.INTERNAL_SERVER_ERROR;
|
|
40
37
|
this.log(this.exception);
|
|
41
38
|
socket.send(JSON.stringify({
|
|
42
39
|
event: 'error',
|
|
43
40
|
data: this.format({
|
|
44
|
-
status,
|
|
41
|
+
status: this.wsStatus,
|
|
45
42
|
meta: meta?.meta,
|
|
46
43
|
}),
|
|
47
44
|
}));
|
|
@@ -55,6 +52,14 @@ let AllExceptionsFilter = class AllExceptionsFilter {
|
|
|
55
52
|
hint(exception) {
|
|
56
53
|
return (exception?.getResponse?.()?.message ?? exception.message);
|
|
57
54
|
}
|
|
55
|
+
get httpStatus() {
|
|
56
|
+
return this.exception instanceof HttpException
|
|
57
|
+
? this.exception.getStatus()
|
|
58
|
+
: this.exception?.meta?.status ?? HttpStatus.INTERNAL_SERVER_ERROR;
|
|
59
|
+
}
|
|
60
|
+
get wsStatus() {
|
|
61
|
+
return this.exception?.meta?.status ?? HttpStatus.INTERNAL_SERVER_ERROR;
|
|
62
|
+
}
|
|
58
63
|
format(data) {
|
|
59
64
|
return {
|
|
60
65
|
code: this.code(this.exception),
|
|
@@ -9,6 +9,8 @@ export declare class AllExceptionsFilter implements ExceptionFilter {
|
|
|
9
9
|
private _rpc;
|
|
10
10
|
private code;
|
|
11
11
|
private hint;
|
|
12
|
+
protected get httpStatus(): any;
|
|
13
|
+
protected get wsStatus(): any;
|
|
12
14
|
protected format(data: Record<string, unknown>): {
|
|
13
15
|
code: string;
|
|
14
16
|
hint: string | [string];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biorate/nestjs-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "NestJS tools",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"keywords": [],
|
|
46
46
|
"author": "llevkin",
|
|
47
47
|
"license": "MIT",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "90bfe8f2c4e04c99bb273171a15a185b818d5104",
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@nestjs/common": ">=10.4.15",
|
|
51
51
|
"@nestjs/core": ">=10.4.15",
|