@xfe-repo/bff-endpoint 1.2.11 → 1.5.1
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/{chunk-FLYBXJYN.mjs → chunk-5FTZ5OJ5.mjs} +2 -2
- package/dist/{chunk-AH6HKQNT.mjs → chunk-L6OSYIFY.mjs} +6 -6
- package/dist/endpoint.decorator.js +1 -1
- package/dist/endpoint.decorator.mjs +1 -1
- package/dist/endpoint.module.js +6 -6
- package/dist/endpoint.module.mjs +2 -2
- package/dist/endpoints.decorator.js +3 -3
- package/dist/endpoints.decorator.mjs +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +128 -128
- package/dist/index.mjs +4 -4
- package/package.json +9 -8
- package/dist/{chunk-B44QRTRJ.mjs → chunk-G3XZMNHG.mjs} +1 -1
- package/dist/{chunk-ZIZ27E2R.mjs → chunk-MFNQSBS5.mjs} +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiSuccessResponse
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MFNQSBS5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-Q7G5RLD4.mjs";
|
|
7
7
|
|
|
8
8
|
// src/endpoints.decorator.ts
|
|
9
|
-
import { ApiHeaders, ApiTags } from "@xfe-repo/bff-core";
|
|
10
9
|
import { applyDecorators, Controller } from "@nestjs/common";
|
|
10
|
+
import { ApiHeaders, ApiTags } from "@xfe-repo/bff-core";
|
|
11
11
|
function Endpoints(options) {
|
|
12
12
|
const { route, tag, headers = [] } = options;
|
|
13
13
|
const defaultHeaders = [
|
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
API_RAW_RESPONSE,
|
|
3
3
|
API_SUCCESS_METHOD_RESPONSE,
|
|
4
4
|
API_SUCCESS_RESPONSE
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MFNQSBS5.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name,
|
|
8
8
|
__publicField
|
|
9
9
|
} from "./chunk-Q7G5RLD4.mjs";
|
|
10
10
|
|
|
11
11
|
// src/endpoint.module.ts
|
|
12
|
-
import { ValidationPipe } from "@xfe-repo/bff-validation";
|
|
13
12
|
import { Module } from "@nestjs/common";
|
|
14
13
|
import { APP_FILTER, APP_INTERCEPTOR, APP_PIPE } from "@nestjs/core";
|
|
14
|
+
import { ValidationPipe } from "@xfe-repo/bff-validation";
|
|
15
15
|
|
|
16
16
|
// src/apiResponse/ApiResponse.exception.filter.ts
|
|
17
|
-
import { CtxService } from "@xfe-repo/bff-core";
|
|
18
|
-
import { ApiResponseException } from "@xfe-repo/bff-validation";
|
|
19
17
|
import { Catch } from "@nestjs/common";
|
|
20
18
|
import { HttpException, HttpStatus } from "@nestjs/common";
|
|
19
|
+
import { CtxService } from "@xfe-repo/bff-core";
|
|
20
|
+
import { ApiResponseException } from "@xfe-repo/bff-validation";
|
|
21
21
|
function _ts_decorate(decorators, target, key, desc) {
|
|
22
22
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
23
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -101,11 +101,11 @@ ApiResponseExceptionFilter = _ts_decorate([
|
|
|
101
101
|
], ApiResponseExceptionFilter);
|
|
102
102
|
|
|
103
103
|
// src/apiResponse/ApiResponse.interceptor.ts
|
|
104
|
-
import { CtxService as CtxService2 } from "@xfe-repo/bff-core";
|
|
105
|
-
import { createValidationPipe } from "@xfe-repo/bff-validation";
|
|
106
104
|
import { Injectable } from "@nestjs/common";
|
|
107
105
|
import { Reflector } from "@nestjs/core";
|
|
108
106
|
import { DECORATORS } from "@nestjs/swagger/dist/constants";
|
|
107
|
+
import { CtxService as CtxService2 } from "@xfe-repo/bff-core";
|
|
108
|
+
import { createValidationPipe } from "@xfe-repo/bff-validation";
|
|
109
109
|
import { mergeMap } from "rxjs/operators";
|
|
110
110
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
111
111
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -24,9 +24,9 @@ __export(endpoint_decorator_exports, {
|
|
|
24
24
|
Endpoint: () => Endpoint
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(endpoint_decorator_exports);
|
|
27
|
-
var import_bff_core = require("@xfe-repo/bff-core");
|
|
28
27
|
var import_common = require("@nestjs/common");
|
|
29
28
|
var import_common2 = require("@nestjs/common");
|
|
29
|
+
var import_bff_core = require("@xfe-repo/bff-core");
|
|
30
30
|
var METHOD_MAP = {
|
|
31
31
|
GET: import_common2.Get,
|
|
32
32
|
POST: import_common2.Post,
|
package/dist/endpoint.module.js
CHANGED
|
@@ -26,15 +26,15 @@ __export(endpoint_module_exports, {
|
|
|
26
26
|
EndpointModule: () => EndpointModule
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(endpoint_module_exports);
|
|
29
|
-
var import_bff_validation3 = require("@xfe-repo/bff-validation");
|
|
30
29
|
var import_common6 = require("@nestjs/common");
|
|
31
30
|
var import_core2 = require("@nestjs/core");
|
|
31
|
+
var import_bff_validation3 = require("@xfe-repo/bff-validation");
|
|
32
32
|
|
|
33
33
|
// src/apiResponse/ApiResponse.exception.filter.ts
|
|
34
|
-
var import_bff_core = require("@xfe-repo/bff-core");
|
|
35
|
-
var import_bff_validation = require("@xfe-repo/bff-validation");
|
|
36
34
|
var import_common = require("@nestjs/common");
|
|
37
35
|
var import_common2 = require("@nestjs/common");
|
|
36
|
+
var import_bff_core = require("@xfe-repo/bff-core");
|
|
37
|
+
var import_bff_validation = require("@xfe-repo/bff-validation");
|
|
38
38
|
function _ts_decorate(decorators, target, key, desc) {
|
|
39
39
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
40
40
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -118,11 +118,11 @@ ApiResponseExceptionFilter = _ts_decorate([
|
|
|
118
118
|
], ApiResponseExceptionFilter);
|
|
119
119
|
|
|
120
120
|
// src/apiResponse/ApiResponse.interceptor.ts
|
|
121
|
-
var import_bff_core3 = require("@xfe-repo/bff-core");
|
|
122
|
-
var import_bff_validation2 = require("@xfe-repo/bff-validation");
|
|
123
121
|
var import_common5 = require("@nestjs/common");
|
|
124
122
|
var import_core = require("@nestjs/core");
|
|
125
123
|
var import_constants2 = require("@nestjs/swagger/dist/constants");
|
|
124
|
+
var import_bff_core3 = require("@xfe-repo/bff-core");
|
|
125
|
+
var import_bff_validation2 = require("@xfe-repo/bff-validation");
|
|
126
126
|
var import_operators = require("rxjs/operators");
|
|
127
127
|
|
|
128
128
|
// src/apiResponse/ApiRawResponse.decorator.ts
|
|
@@ -130,9 +130,9 @@ var import_common3 = require("@nestjs/common");
|
|
|
130
130
|
var API_RAW_RESPONSE = "API_RAW_RESPONSE";
|
|
131
131
|
|
|
132
132
|
// src/apiResponse/ApiSuccessResponse.decorator.ts
|
|
133
|
-
var import_bff_core2 = require("@xfe-repo/bff-core");
|
|
134
133
|
var import_common4 = require("@nestjs/common");
|
|
135
134
|
var import_constants = require("@nestjs/swagger/dist/constants");
|
|
135
|
+
var import_bff_core2 = require("@xfe-repo/bff-core");
|
|
136
136
|
var import_class_transformer = require("class-transformer");
|
|
137
137
|
var import_class_validator = require("class-validator");
|
|
138
138
|
var API_SUCCESS_RESPONSE = "API_SUCCESS_RESPONSE";
|
package/dist/endpoint.module.mjs
CHANGED
|
@@ -26,11 +26,13 @@ __export(endpoints_decorator_exports, {
|
|
|
26
26
|
Endpoints: () => Endpoints
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(endpoints_decorator_exports);
|
|
29
|
+
var import_common3 = require("@nestjs/common");
|
|
30
|
+
var import_bff_core2 = require("@xfe-repo/bff-core");
|
|
29
31
|
|
|
30
32
|
// src/apiResponse/ApiSuccessResponse.decorator.ts
|
|
31
|
-
var import_bff_core = require("@xfe-repo/bff-core");
|
|
32
33
|
var import_common2 = require("@nestjs/common");
|
|
33
34
|
var import_constants = require("@nestjs/swagger/dist/constants");
|
|
35
|
+
var import_bff_core = require("@xfe-repo/bff-core");
|
|
34
36
|
var import_class_transformer = require("class-transformer");
|
|
35
37
|
var import_class_validator = require("class-validator");
|
|
36
38
|
|
|
@@ -171,8 +173,6 @@ function withApiSuccessResponse(Base, isArray) {
|
|
|
171
173
|
__name(withApiSuccessResponse, "withApiSuccessResponse");
|
|
172
174
|
|
|
173
175
|
// src/endpoints.decorator.ts
|
|
174
|
-
var import_bff_core2 = require("@xfe-repo/bff-core");
|
|
175
|
-
var import_common3 = require("@nestjs/common");
|
|
176
176
|
function Endpoints(options) {
|
|
177
177
|
const { route, tag, headers = [] } = options;
|
|
178
178
|
const defaultHeaders = [
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { EndpointModule } from './endpoint.module.mjs';
|
|
1
2
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
3
|
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
3
|
-
import { CtxService } from '@xfe-repo/bff-core';
|
|
4
4
|
import { Reflector } from '@nestjs/core';
|
|
5
|
+
import { CtxService } from '@xfe-repo/bff-core';
|
|
5
6
|
import { Observable } from 'rxjs';
|
|
6
|
-
export { EndpointModule } from './endpoint.module.mjs';
|
|
7
7
|
export { Endpoint, EndpointOptions, HttpMethod, MethodDecoratorFn } from './endpoint.decorator.mjs';
|
|
8
8
|
export { Endpoints, EndpointsOptions } from './endpoints.decorator.mjs';
|
|
9
9
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { EndpointModule } from './endpoint.module.js';
|
|
1
2
|
import * as _nestjs_common from '@nestjs/common';
|
|
2
3
|
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
3
|
-
import { CtxService } from '@xfe-repo/bff-core';
|
|
4
4
|
import { Reflector } from '@nestjs/core';
|
|
5
|
+
import { CtxService } from '@xfe-repo/bff-core';
|
|
5
6
|
import { Observable } from 'rxjs';
|
|
6
|
-
export { EndpointModule } from './endpoint.module.js';
|
|
7
7
|
export { Endpoint, EndpointOptions, HttpMethod, MethodDecoratorFn } from './endpoint.decorator.js';
|
|
8
8
|
export { Endpoints, EndpointsOptions } from './endpoints.decorator.js';
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -36,36 +36,128 @@ __export(index_exports, {
|
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(index_exports);
|
|
38
38
|
|
|
39
|
-
// src/
|
|
39
|
+
// src/endpoint.module.ts
|
|
40
|
+
var import_common6 = require("@nestjs/common");
|
|
41
|
+
var import_core2 = require("@nestjs/core");
|
|
42
|
+
var import_bff_validation3 = require("@xfe-repo/bff-validation");
|
|
43
|
+
|
|
44
|
+
// src/apiResponse/ApiResponse.exception.filter.ts
|
|
40
45
|
var import_common = require("@nestjs/common");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
46
|
+
var import_common2 = require("@nestjs/common");
|
|
47
|
+
var import_bff_core = require("@xfe-repo/bff-core");
|
|
48
|
+
var import_bff_validation = require("@xfe-repo/bff-validation");
|
|
49
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
50
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
51
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
52
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
53
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
54
|
+
}
|
|
55
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
56
|
+
function _ts_metadata(k, v) {
|
|
57
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
58
|
+
}
|
|
59
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
60
|
+
var _ApiResponseExceptionFilter = class _ApiResponseExceptionFilter {
|
|
61
|
+
constructor(ctx) {
|
|
62
|
+
__publicField(this, "ctx");
|
|
63
|
+
this.ctx = ctx;
|
|
64
|
+
}
|
|
65
|
+
catch(exception, host) {
|
|
66
|
+
if (!exception) return;
|
|
67
|
+
const apiResponse = this.handleException(exception, host);
|
|
68
|
+
const context = host.switchToHttp();
|
|
69
|
+
const response = context.getResponse();
|
|
70
|
+
const defaultError = {
|
|
71
|
+
code: import_common2.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
72
|
+
data: {},
|
|
73
|
+
msg: "\u5C0F\u6613\u7D2F\u4E86\uFF0C\u8BA9\u5C0F\u6613\u4F11\u606F\u4E00\u4E0B\u5427~"
|
|
74
|
+
};
|
|
75
|
+
response.status(import_common2.HttpStatus.OK).json({
|
|
76
|
+
code: apiResponse?.code || defaultError.code,
|
|
77
|
+
msg: apiResponse?.msg || defaultError.msg,
|
|
78
|
+
data: apiResponse?.data || defaultError.data,
|
|
79
|
+
debug: {
|
|
80
|
+
stack: apiResponse?.stack || "\u672A\u77E5\u7684stack\u9519\u8BEF",
|
|
81
|
+
tracks: this.ctx.tracks
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
handleException(exception, _host) {
|
|
86
|
+
if (exception instanceof import_common2.HttpException) {
|
|
87
|
+
return {
|
|
88
|
+
code: exception.getStatus(),
|
|
89
|
+
msg: exception.message,
|
|
90
|
+
data: exception.getResponse(),
|
|
91
|
+
stack: exception.stack
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (exception instanceof import_bff_validation.ApiResponseException) {
|
|
95
|
+
return {
|
|
96
|
+
code: exception.code,
|
|
97
|
+
msg: exception.msg,
|
|
98
|
+
data: exception.data,
|
|
99
|
+
stack: exception.stack
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (exception instanceof Error) {
|
|
103
|
+
return {
|
|
104
|
+
code: import_common2.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
105
|
+
msg: exception.message,
|
|
106
|
+
data: exception,
|
|
107
|
+
stack: exception.stack
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
if (typeof exception === "string") {
|
|
111
|
+
return {
|
|
112
|
+
code: import_common2.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
113
|
+
msg: exception,
|
|
114
|
+
data: {},
|
|
115
|
+
stack: new Error(exception).stack
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return exception;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
__name(_ApiResponseExceptionFilter, "ApiResponseExceptionFilter");
|
|
122
|
+
var ApiResponseExceptionFilter = _ApiResponseExceptionFilter;
|
|
123
|
+
ApiResponseExceptionFilter = _ts_decorate([
|
|
124
|
+
(0, import_common.Catch)(),
|
|
125
|
+
_ts_metadata("design:type", Function),
|
|
126
|
+
_ts_metadata("design:paramtypes", [
|
|
127
|
+
typeof import_bff_core.CtxService === "undefined" ? Object : import_bff_core.CtxService
|
|
128
|
+
])
|
|
129
|
+
], ApiResponseExceptionFilter);
|
|
43
130
|
|
|
44
131
|
// src/apiResponse/ApiResponse.interceptor.ts
|
|
45
|
-
var
|
|
46
|
-
var import_bff_validation = require("@xfe-repo/bff-validation");
|
|
47
|
-
var import_common3 = require("@nestjs/common");
|
|
132
|
+
var import_common5 = require("@nestjs/common");
|
|
48
133
|
var import_core = require("@nestjs/core");
|
|
49
134
|
var import_constants2 = require("@nestjs/swagger/dist/constants");
|
|
135
|
+
var import_bff_core3 = require("@xfe-repo/bff-core");
|
|
136
|
+
var import_bff_validation2 = require("@xfe-repo/bff-validation");
|
|
50
137
|
var import_operators = require("rxjs/operators");
|
|
51
138
|
|
|
139
|
+
// src/apiResponse/ApiRawResponse.decorator.ts
|
|
140
|
+
var import_common3 = require("@nestjs/common");
|
|
141
|
+
var API_RAW_RESPONSE = "API_RAW_RESPONSE";
|
|
142
|
+
var ApiRawResponse = /* @__PURE__ */ __name(() => (0, import_common3.SetMetadata)(API_RAW_RESPONSE, true), "ApiRawResponse");
|
|
143
|
+
|
|
52
144
|
// src/apiResponse/ApiSuccessResponse.decorator.ts
|
|
53
|
-
var
|
|
54
|
-
var import_common2 = require("@nestjs/common");
|
|
145
|
+
var import_common4 = require("@nestjs/common");
|
|
55
146
|
var import_constants = require("@nestjs/swagger/dist/constants");
|
|
147
|
+
var import_bff_core2 = require("@xfe-repo/bff-core");
|
|
56
148
|
var import_class_transformer = require("class-transformer");
|
|
57
149
|
var import_class_validator = require("class-validator");
|
|
58
|
-
function
|
|
150
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
59
151
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
60
152
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
61
153
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
62
154
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
63
155
|
}
|
|
64
|
-
__name(
|
|
65
|
-
function
|
|
156
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
157
|
+
function _ts_metadata2(k, v) {
|
|
66
158
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
67
159
|
}
|
|
68
|
-
__name(
|
|
160
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
69
161
|
var API_SUCCESS_RESPONSE = "API_SUCCESS_RESPONSE";
|
|
70
162
|
var API_SUCCESS_METHOD_RESPONSE = "API_SUCCESS_METHOD_RESPONSE";
|
|
71
163
|
function ApiSuccessResponse() {
|
|
@@ -136,39 +228,39 @@ function withApiSuccessResponse(Base, isArray) {
|
|
|
136
228
|
var _a;
|
|
137
229
|
let ApiResponse2 = (_a = class {
|
|
138
230
|
constructor() {
|
|
139
|
-
__publicField(this, "code",
|
|
231
|
+
__publicField(this, "code", import_common4.HttpStatus.INTERNAL_SERVER_ERROR);
|
|
140
232
|
__publicField(this, "msg", "\u5C0F\u6613\u5F88\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5~");
|
|
141
233
|
__publicField(this, "traceid");
|
|
142
234
|
__publicField(this, "data");
|
|
143
235
|
}
|
|
144
236
|
}, __name(_a, "ApiResponse"), _a);
|
|
145
|
-
|
|
146
|
-
(0,
|
|
237
|
+
_ts_decorate2([
|
|
238
|
+
(0, import_bff_core2.ApiProperty)({
|
|
147
239
|
example: 200,
|
|
148
240
|
description: "\u54CD\u5E94\u72B6\u6001\u7801, \u6B64\u5904\u7EA6\u5B9A 0 - 100000 \u533A\u95F4\u5BA2\u6237\u7AEFToast\u5904\u7406, \u5927\u4E8E 100000 \u4E3A\u81EA\u5B9A\u4E49\u5904\u7406"
|
|
149
241
|
}),
|
|
150
242
|
(0, import_class_validator.IsInt)(),
|
|
151
243
|
(0, import_class_validator.IsNotEmpty)(),
|
|
152
|
-
|
|
244
|
+
_ts_metadata2("design:type", Number)
|
|
153
245
|
], ApiResponse2.prototype, "code", void 0);
|
|
154
|
-
|
|
155
|
-
(0,
|
|
246
|
+
_ts_decorate2([
|
|
247
|
+
(0, import_bff_core2.ApiProperty)({
|
|
156
248
|
description: "\u9519\u8BEF\u4FE1\u606F"
|
|
157
249
|
}),
|
|
158
250
|
(0, import_class_validator.IsString)(),
|
|
159
251
|
(0, import_class_validator.IsNotEmpty)(),
|
|
160
|
-
|
|
252
|
+
_ts_metadata2("design:type", String)
|
|
161
253
|
], ApiResponse2.prototype, "msg", void 0);
|
|
162
|
-
|
|
163
|
-
(0,
|
|
254
|
+
_ts_decorate2([
|
|
255
|
+
(0, import_bff_core2.ApiPropertyOptional)({
|
|
164
256
|
description: "\u9519\u8BEF\u4FE1\u606F\u8FFD\u8E2Aid"
|
|
165
257
|
}),
|
|
166
258
|
(0, import_class_validator.IsString)(),
|
|
167
259
|
(0, import_class_validator.IsOptional)(),
|
|
168
|
-
|
|
260
|
+
_ts_metadata2("design:type", String)
|
|
169
261
|
], ApiResponse2.prototype, "traceid", void 0);
|
|
170
|
-
|
|
171
|
-
(0,
|
|
262
|
+
_ts_decorate2([
|
|
263
|
+
(0, import_bff_core2.ApiProperty)({
|
|
172
264
|
description: "\u54CD\u5E94\u6570\u636E",
|
|
173
265
|
type: isArray ? [
|
|
174
266
|
Base
|
|
@@ -180,24 +272,24 @@ function withApiSuccessResponse(Base, isArray) {
|
|
|
180
272
|
}),
|
|
181
273
|
(0, import_class_validator.IsNotEmpty)(),
|
|
182
274
|
IsArrayOrObject(isArray),
|
|
183
|
-
|
|
275
|
+
_ts_metadata2("design:type", Object)
|
|
184
276
|
], ApiResponse2.prototype, "data", void 0);
|
|
185
277
|
return mixin(ApiResponse2, `${ApiResponse2.name}<${Base.name}>`);
|
|
186
278
|
}
|
|
187
279
|
__name(withApiSuccessResponse, "withApiSuccessResponse");
|
|
188
280
|
|
|
189
281
|
// src/apiResponse/ApiResponse.interceptor.ts
|
|
190
|
-
function
|
|
282
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
191
283
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
192
284
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
193
285
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
194
286
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
195
287
|
}
|
|
196
|
-
__name(
|
|
197
|
-
function
|
|
288
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
289
|
+
function _ts_metadata3(k, v) {
|
|
198
290
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
199
291
|
}
|
|
200
|
-
__name(
|
|
292
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
201
293
|
var _ApiResponseInterceptor = class _ApiResponseInterceptor {
|
|
202
294
|
constructor(reflector, ctx) {
|
|
203
295
|
__publicField(this, "reflector");
|
|
@@ -207,7 +299,7 @@ var _ApiResponseInterceptor = class _ApiResponseInterceptor {
|
|
|
207
299
|
__publicField(this, "contextHandler");
|
|
208
300
|
this.reflector = reflector;
|
|
209
301
|
this.ctx = ctx;
|
|
210
|
-
this.validationPipe = (0,
|
|
302
|
+
this.validationPipe = (0, import_bff_validation2.createValidationPipe)({
|
|
211
303
|
// 配合配置 validationPipe.transform({ type: 'custom' }) 时使用
|
|
212
304
|
validateCustomDecorators: true
|
|
213
305
|
});
|
|
@@ -249,106 +341,14 @@ var _ApiResponseInterceptor = class _ApiResponseInterceptor {
|
|
|
249
341
|
};
|
|
250
342
|
__name(_ApiResponseInterceptor, "ApiResponseInterceptor");
|
|
251
343
|
var ApiResponseInterceptor = _ApiResponseInterceptor;
|
|
252
|
-
ApiResponseInterceptor =
|
|
253
|
-
(0,
|
|
254
|
-
_ts_metadata2("design:type", Function),
|
|
255
|
-
_ts_metadata2("design:paramtypes", [
|
|
256
|
-
typeof import_core.Reflector === "undefined" ? Object : import_core.Reflector,
|
|
257
|
-
typeof import_bff_core2.CtxService === "undefined" ? Object : import_bff_core2.CtxService
|
|
258
|
-
])
|
|
259
|
-
], ApiResponseInterceptor);
|
|
260
|
-
|
|
261
|
-
// src/endpoint.module.ts
|
|
262
|
-
var import_bff_validation3 = require("@xfe-repo/bff-validation");
|
|
263
|
-
var import_common6 = require("@nestjs/common");
|
|
264
|
-
var import_core2 = require("@nestjs/core");
|
|
265
|
-
|
|
266
|
-
// src/apiResponse/ApiResponse.exception.filter.ts
|
|
267
|
-
var import_bff_core3 = require("@xfe-repo/bff-core");
|
|
268
|
-
var import_bff_validation2 = require("@xfe-repo/bff-validation");
|
|
269
|
-
var import_common4 = require("@nestjs/common");
|
|
270
|
-
var import_common5 = require("@nestjs/common");
|
|
271
|
-
function _ts_decorate3(decorators, target, key, desc) {
|
|
272
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
273
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
274
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
275
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
276
|
-
}
|
|
277
|
-
__name(_ts_decorate3, "_ts_decorate");
|
|
278
|
-
function _ts_metadata3(k, v) {
|
|
279
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
280
|
-
}
|
|
281
|
-
__name(_ts_metadata3, "_ts_metadata");
|
|
282
|
-
var _ApiResponseExceptionFilter = class _ApiResponseExceptionFilter {
|
|
283
|
-
constructor(ctx) {
|
|
284
|
-
__publicField(this, "ctx");
|
|
285
|
-
this.ctx = ctx;
|
|
286
|
-
}
|
|
287
|
-
catch(exception, host) {
|
|
288
|
-
if (!exception) return;
|
|
289
|
-
const apiResponse = this.handleException(exception, host);
|
|
290
|
-
const context = host.switchToHttp();
|
|
291
|
-
const response = context.getResponse();
|
|
292
|
-
const defaultError = {
|
|
293
|
-
code: import_common5.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
294
|
-
data: {},
|
|
295
|
-
msg: "\u5C0F\u6613\u7D2F\u4E86\uFF0C\u8BA9\u5C0F\u6613\u4F11\u606F\u4E00\u4E0B\u5427~"
|
|
296
|
-
};
|
|
297
|
-
response.status(import_common5.HttpStatus.OK).json({
|
|
298
|
-
code: apiResponse?.code || defaultError.code,
|
|
299
|
-
msg: apiResponse?.msg || defaultError.msg,
|
|
300
|
-
data: apiResponse?.data || defaultError.data,
|
|
301
|
-
debug: {
|
|
302
|
-
stack: apiResponse?.stack || "\u672A\u77E5\u7684stack\u9519\u8BEF",
|
|
303
|
-
tracks: this.ctx.tracks
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
handleException(exception, _host) {
|
|
308
|
-
if (exception instanceof import_common5.HttpException) {
|
|
309
|
-
return {
|
|
310
|
-
code: exception.getStatus(),
|
|
311
|
-
msg: exception.message,
|
|
312
|
-
data: exception.getResponse(),
|
|
313
|
-
stack: exception.stack
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
if (exception instanceof import_bff_validation2.ApiResponseException) {
|
|
317
|
-
return {
|
|
318
|
-
code: exception.code,
|
|
319
|
-
msg: exception.msg,
|
|
320
|
-
data: exception.data,
|
|
321
|
-
stack: exception.stack
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
if (exception instanceof Error) {
|
|
325
|
-
return {
|
|
326
|
-
code: import_common5.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
327
|
-
msg: exception.message,
|
|
328
|
-
data: exception,
|
|
329
|
-
stack: exception.stack
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
if (typeof exception === "string") {
|
|
333
|
-
return {
|
|
334
|
-
code: import_common5.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
335
|
-
msg: exception,
|
|
336
|
-
data: {},
|
|
337
|
-
stack: new Error(exception).stack
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
return exception;
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
__name(_ApiResponseExceptionFilter, "ApiResponseExceptionFilter");
|
|
344
|
-
var ApiResponseExceptionFilter = _ApiResponseExceptionFilter;
|
|
345
|
-
ApiResponseExceptionFilter = _ts_decorate3([
|
|
346
|
-
(0, import_common4.Catch)(),
|
|
344
|
+
ApiResponseInterceptor = _ts_decorate3([
|
|
345
|
+
(0, import_common5.Injectable)(),
|
|
347
346
|
_ts_metadata3("design:type", Function),
|
|
348
347
|
_ts_metadata3("design:paramtypes", [
|
|
348
|
+
typeof import_core.Reflector === "undefined" ? Object : import_core.Reflector,
|
|
349
349
|
typeof import_bff_core3.CtxService === "undefined" ? Object : import_bff_core3.CtxService
|
|
350
350
|
])
|
|
351
|
-
],
|
|
351
|
+
], ApiResponseInterceptor);
|
|
352
352
|
|
|
353
353
|
// src/endpoint.module.ts
|
|
354
354
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
@@ -382,9 +382,9 @@ EndpointModule = _ts_decorate4([
|
|
|
382
382
|
], EndpointModule);
|
|
383
383
|
|
|
384
384
|
// src/endpoint.decorator.ts
|
|
385
|
-
var import_bff_core4 = require("@xfe-repo/bff-core");
|
|
386
385
|
var import_common7 = require("@nestjs/common");
|
|
387
386
|
var import_common8 = require("@nestjs/common");
|
|
387
|
+
var import_bff_core4 = require("@xfe-repo/bff-core");
|
|
388
388
|
var METHOD_MAP = {
|
|
389
389
|
GET: import_common8.Get,
|
|
390
390
|
POST: import_common8.Post,
|
|
@@ -440,8 +440,8 @@ function Endpoint(options) {
|
|
|
440
440
|
__name(Endpoint, "Endpoint");
|
|
441
441
|
|
|
442
442
|
// src/endpoints.decorator.ts
|
|
443
|
-
var import_bff_core5 = require("@xfe-repo/bff-core");
|
|
444
443
|
var import_common9 = require("@nestjs/common");
|
|
444
|
+
var import_bff_core5 = require("@xfe-repo/bff-core");
|
|
445
445
|
function Endpoints(options) {
|
|
446
446
|
const { route, tag, headers = [] } = options;
|
|
447
447
|
const defaultHeaders = [
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Endpoint
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-G3XZMNHG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ApiResponseInterceptor,
|
|
6
6
|
EndpointModule
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L6OSYIFY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Endpoints
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5FTZ5OJ5.mjs";
|
|
11
11
|
import {
|
|
12
12
|
API_RAW_RESPONSE,
|
|
13
13
|
API_SUCCESS_METHOD_RESPONSE,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
ApiRawResponse,
|
|
16
16
|
ApiSuccessMethodResponse,
|
|
17
17
|
ApiSuccessResponse
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MFNQSBS5.mjs";
|
|
19
19
|
import "./chunk-Q7G5RLD4.mjs";
|
|
20
20
|
export {
|
|
21
21
|
API_RAW_RESPONSE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/bff-endpoint",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,19 +25,20 @@
|
|
|
25
25
|
"@nestjs/swagger": "11.2.6",
|
|
26
26
|
"class-transformer": "^0.5.1",
|
|
27
27
|
"class-validator": "^0.14.3",
|
|
28
|
+
"eslint": "8.57.1",
|
|
28
29
|
"reflect-metadata": "^0.2.2",
|
|
29
30
|
"rxjs": "^7.8.2",
|
|
30
|
-
"@xfe-repo/bff-core": "1.
|
|
31
|
-
"@xfe-repo/bff-validation": "1.
|
|
31
|
+
"@xfe-repo/bff-core": "1.5.1",
|
|
32
|
+
"@xfe-repo/bff-validation": "1.5.1"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@nestjs/testing": "11.1.13",
|
|
35
36
|
"@types/jest": "^30.0.0",
|
|
36
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^20.17.0",
|
|
37
38
|
"jest": "^30.2.0",
|
|
38
|
-
"@xfe-repo/
|
|
39
|
-
"@xfe-repo/jest-config": "1.
|
|
40
|
-
"@xfe-repo/
|
|
39
|
+
"@xfe-repo/typescript-config": "1.5.1",
|
|
40
|
+
"@xfe-repo/jest-config": "1.5.1",
|
|
41
|
+
"@xfe-repo/eslint-config": "1.5.1"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {},
|
|
43
44
|
"publishConfig": {
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"scripts": {
|
|
47
48
|
"build": "tsup",
|
|
48
49
|
"dev": "tsup --watch",
|
|
49
|
-
"lint": "eslint \"src/**/*.ts*\"",
|
|
50
|
+
"lint": "eslint \"src/**/*.ts*\" --fix",
|
|
50
51
|
"test": "jest",
|
|
51
52
|
"test:watch": "jest --watch",
|
|
52
53
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-Q7G5RLD4.mjs";
|
|
4
4
|
|
|
5
5
|
// src/endpoint.decorator.ts
|
|
6
|
-
import { ApiOperation, ApiResponse } from "@xfe-repo/bff-core";
|
|
7
6
|
import { applyDecorators } from "@nestjs/common";
|
|
8
7
|
import { Delete, Get, Head, Options, Patch, Post, Put } from "@nestjs/common";
|
|
8
|
+
import { ApiOperation, ApiResponse } from "@xfe-repo/bff-core";
|
|
9
9
|
var METHOD_MAP = {
|
|
10
10
|
GET: Get,
|
|
11
11
|
POST: Post,
|
|
@@ -9,9 +9,9 @@ var API_RAW_RESPONSE = "API_RAW_RESPONSE";
|
|
|
9
9
|
var ApiRawResponse = /* @__PURE__ */ __name(() => SetMetadata(API_RAW_RESPONSE, true), "ApiRawResponse");
|
|
10
10
|
|
|
11
11
|
// src/apiResponse/ApiSuccessResponse.decorator.ts
|
|
12
|
-
import { ApiProperty, ApiPropertyOptional } from "@xfe-repo/bff-core";
|
|
13
12
|
import { HttpStatus } from "@nestjs/common";
|
|
14
13
|
import { DECORATORS } from "@nestjs/swagger/dist/constants";
|
|
14
|
+
import { ApiProperty, ApiPropertyOptional } from "@xfe-repo/bff-core";
|
|
15
15
|
import { Type } from "class-transformer";
|
|
16
16
|
import { IsArray, IsInt, IsNotEmpty, IsObject, IsOptional, IsString, ValidateNested } from "class-validator";
|
|
17
17
|
function _ts_decorate(decorators, target, key, desc) {
|