@saihu/common 1.1.24 → 1.1.26
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/dto/base-response.dto.d.ts +14 -0
- package/dist/dto/base-response.dto.js +27 -0
- package/dist/logger/saihu-logger.service.d.ts.map +1 -1
- package/dist/logger/saihu-logger.service.js +46 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +1 -0
- package/dist/util/number.d.ts +2 -0
- package/dist/util/number.d.ts.map +1 -0
- package/dist/util/number.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class BaseResponseDto<T> {
|
|
2
|
+
code: number;
|
|
3
|
+
msg: string;
|
|
4
|
+
data: T | null;
|
|
5
|
+
constructor(code: number, msg: string, data?: T | null);
|
|
6
|
+
static success<T>(data: T): BaseResponseDto<T>;
|
|
7
|
+
static successWithMessage<T>(msg: string, data: T): BaseResponseDto<T>;
|
|
8
|
+
static error<T>(code: number, msg: string): BaseResponseDto<T>;
|
|
9
|
+
static readonly CODE_NOT_FOUND = 404;
|
|
10
|
+
static readonly CODE_UNAUTHORIZED = 401;
|
|
11
|
+
static readonly CODE_FORBIDDEN = 403;
|
|
12
|
+
static readonly CODE_BAD_REQUEST = 400;
|
|
13
|
+
static readonly CODE_SERVER_ERROR = 500;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseResponseDto = void 0;
|
|
4
|
+
// src/dto/base-response.dto.ts
|
|
5
|
+
class BaseResponseDto {
|
|
6
|
+
constructor(code, msg, data = null) {
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.msg = msg;
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
static success(data) {
|
|
12
|
+
return new BaseResponseDto(0, 'success', data);
|
|
13
|
+
}
|
|
14
|
+
static successWithMessage(msg, data) {
|
|
15
|
+
return new BaseResponseDto(0, msg, data);
|
|
16
|
+
}
|
|
17
|
+
static error(code, msg) {
|
|
18
|
+
return new BaseResponseDto(code, msg, null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.BaseResponseDto = BaseResponseDto;
|
|
22
|
+
// Common error codes
|
|
23
|
+
BaseResponseDto.CODE_NOT_FOUND = 404;
|
|
24
|
+
BaseResponseDto.CODE_UNAUTHORIZED = 401;
|
|
25
|
+
BaseResponseDto.CODE_FORBIDDEN = 403;
|
|
26
|
+
BaseResponseDto.CODE_BAD_REQUEST = 400;
|
|
27
|
+
BaseResponseDto.CODE_SERVER_ERROR = 500;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saihu-logger.service.d.ts","sourceRoot":"","sources":["../../src/logger/saihu-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,WAAY,YAAW,aAAa;IAC/C,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBlC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"saihu-logger.service.d.ts","sourceRoot":"","sources":["../../src/logger/saihu-logger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,WAAY,YAAW,aAAa;IAC/C,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBlC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBpD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM;IAgBnC,KAAK;IACL,OAAO;CACR"}
|
|
@@ -29,9 +29,55 @@ class SaihuLogger {
|
|
|
29
29
|
console.log(`[${context}]`, message);
|
|
30
30
|
}
|
|
31
31
|
error(message, trace, context) {
|
|
32
|
+
// Hide Nest internal errors
|
|
33
|
+
if (context === null || context === void 0 ? void 0 : context.includes('InstanceLoader'))
|
|
34
|
+
return;
|
|
35
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RoutesResolver'))
|
|
36
|
+
return;
|
|
37
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RouterExplorer'))
|
|
38
|
+
return;
|
|
39
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestFactory'))
|
|
40
|
+
return;
|
|
41
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestApplication'))
|
|
42
|
+
return;
|
|
43
|
+
if (context === null || context === void 0 ? void 0 : context.includes('ClientProxy'))
|
|
44
|
+
return;
|
|
45
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestMicroservice'))
|
|
46
|
+
return;
|
|
47
|
+
if (context === null || context === void 0 ? void 0 : context.includes('AmqpConnection'))
|
|
48
|
+
return;
|
|
49
|
+
if (context === null || context === void 0 ? void 0 : context.includes('MicroserviceConfiguration'))
|
|
50
|
+
return;
|
|
51
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RabbitMQModule'))
|
|
52
|
+
return;
|
|
53
|
+
if (context === null || context === void 0 ? void 0 : context.includes('WebSocketsController'))
|
|
54
|
+
return;
|
|
32
55
|
console.error(`[${context}]`, message, trace);
|
|
33
56
|
}
|
|
34
57
|
warn(message, context) {
|
|
58
|
+
// Hide Nest internal warnings
|
|
59
|
+
if (context === null || context === void 0 ? void 0 : context.includes('InstanceLoader'))
|
|
60
|
+
return;
|
|
61
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RoutesResolver'))
|
|
62
|
+
return;
|
|
63
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RouterExplorer'))
|
|
64
|
+
return;
|
|
65
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestFactory'))
|
|
66
|
+
return;
|
|
67
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestApplication'))
|
|
68
|
+
return;
|
|
69
|
+
if (context === null || context === void 0 ? void 0 : context.includes('ClientProxy'))
|
|
70
|
+
return;
|
|
71
|
+
if (context === null || context === void 0 ? void 0 : context.includes('NestMicroservice'))
|
|
72
|
+
return;
|
|
73
|
+
if (context === null || context === void 0 ? void 0 : context.includes('AmqpConnection'))
|
|
74
|
+
return;
|
|
75
|
+
if (context === null || context === void 0 ? void 0 : context.includes('MicroserviceConfiguration'))
|
|
76
|
+
return;
|
|
77
|
+
if (context === null || context === void 0 ? void 0 : context.includes('RabbitMQModule'))
|
|
78
|
+
return;
|
|
79
|
+
if (context === null || context === void 0 ? void 0 : context.includes('WebSocketsController'))
|
|
80
|
+
return;
|
|
35
81
|
console.warn(`[${context}]`, message);
|
|
36
82
|
}
|
|
37
83
|
debug() { }
|
package/dist/util/index.d.ts
CHANGED
package/dist/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/util/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/util/number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAExC"}
|