@lark-apaas/fullstack-nestjs-core 1.1.23-alpha.5 → 1.1.23-alpha.7
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/index.cjs +164 -61
- package/dist/index.d.cts +23 -138
- package/dist/index.d.ts +23 -138
- package/dist/index.js +158 -54
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,6 @@ __export(index_exports, {
|
|
|
39
39
|
DevToolsModule: () => import_nestjs_openapi_devtools2.DevToolsModule,
|
|
40
40
|
DevToolsV2Module: () => import_nestjs_openapi_devtools2.DevToolsV2Module,
|
|
41
41
|
FileService: () => FileService,
|
|
42
|
-
PlatformHttpClientService: () => PlatformHttpClientService,
|
|
43
42
|
PlatformModule: () => PlatformModule,
|
|
44
43
|
UserContextMiddleware: () => UserContextMiddleware,
|
|
45
44
|
ViewContextMiddleware: () => ViewContextMiddleware,
|
|
@@ -48,8 +47,8 @@ __export(index_exports, {
|
|
|
48
47
|
module.exports = __toCommonJS(index_exports);
|
|
49
48
|
|
|
50
49
|
// src/modules/platform/module.ts
|
|
51
|
-
var
|
|
52
|
-
var
|
|
50
|
+
var import_common11 = require("@nestjs/common");
|
|
51
|
+
var import_core3 = require("@nestjs/core");
|
|
53
52
|
var import_nestjs_common5 = require("@lark-apaas/nestjs-common");
|
|
54
53
|
var import_config2 = require("@nestjs/config");
|
|
55
54
|
var import_nestjs_observable = require("@lark-apaas/nestjs-observable");
|
|
@@ -760,47 +759,10 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
760
759
|
});
|
|
761
760
|
}
|
|
762
761
|
/**
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
* 与 `create()` 类似,但会自动注册全局拦截器(日志、x-tt-env 透传等)
|
|
766
|
-
* 适用于需要保留平台标准行为,同时又需要添加自定义拦截器的场景
|
|
767
|
-
*
|
|
768
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
769
|
-
* @returns 完整的 HttpClient 实例(带全局拦截器,允许添加更多拦截器)
|
|
770
|
-
*
|
|
771
|
-
* @example
|
|
772
|
-
* ```typescript
|
|
773
|
-
* const client = this.platformHttp.createWithGlobalInterceptors();
|
|
774
|
-
* // 客户端已包含日志和 x-tt-env 拦截器
|
|
775
|
-
* // 可以继续添加自定义拦截器
|
|
776
|
-
* client.interceptors.request.use((config) => {
|
|
777
|
-
* config.headers['x-custom'] = 'value';
|
|
778
|
-
* return config;
|
|
779
|
-
* });
|
|
780
|
-
* ```
|
|
781
|
-
*/
|
|
782
|
-
createWithGlobalInterceptors(options) {
|
|
783
|
-
const client = this.create(options);
|
|
784
|
-
this.registerInterceptorsForClient(client);
|
|
785
|
-
return client;
|
|
786
|
-
}
|
|
787
|
-
/**
|
|
788
|
-
* 注册全局拦截器(用于单例实例)
|
|
762
|
+
* 注册全局拦截器
|
|
789
763
|
*/
|
|
790
764
|
registerGlobalInterceptors() {
|
|
791
|
-
this.
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* 为指定的 HttpClient 实例注册标准拦截器
|
|
795
|
-
*
|
|
796
|
-
* 包含:
|
|
797
|
-
* - 请求日志记录
|
|
798
|
-
* - x-tt-env header 透传
|
|
799
|
-
* - 响应日志记录
|
|
800
|
-
* - 错误日志记录
|
|
801
|
-
*/
|
|
802
|
-
registerInterceptorsForClient(client) {
|
|
803
|
-
client.interceptors.request.use((config) => {
|
|
765
|
+
this.client.interceptors.request.use((config) => {
|
|
804
766
|
this.logger.debug(`Server SDK HTTP Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
805
767
|
const ttEnv = this.requestContext.get("ttEnv");
|
|
806
768
|
if (ttEnv) {
|
|
@@ -814,7 +776,7 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
814
776
|
this.logger.error("Server SDK HTTP Request Error", error, "HttpService");
|
|
815
777
|
return Promise.reject(error);
|
|
816
778
|
});
|
|
817
|
-
client.interceptors.response.use((response) => {
|
|
779
|
+
this.client.interceptors.response.use((response) => {
|
|
818
780
|
this.logger.debug(`Server SDK HTTP Response: ${response.status} ${response.url}`);
|
|
819
781
|
return response;
|
|
820
782
|
}, (error) => {
|
|
@@ -1228,6 +1190,11 @@ FileService = _ts_decorate9([
|
|
|
1228
1190
|
|
|
1229
1191
|
// src/modules/platform/module.ts
|
|
1230
1192
|
var import_nestjs_authzpaas = require("@lark-apaas/nestjs-authzpaas");
|
|
1193
|
+
|
|
1194
|
+
// src/controllers/dev-api-routes.controller.ts
|
|
1195
|
+
var import_common10 = require("@nestjs/common");
|
|
1196
|
+
var import_core2 = require("@nestjs/core");
|
|
1197
|
+
var import_swagger = require("@nestjs/swagger");
|
|
1231
1198
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1232
1199
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1233
1200
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1235,6 +1202,151 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1235
1202
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1236
1203
|
}
|
|
1237
1204
|
__name(_ts_decorate10, "_ts_decorate");
|
|
1205
|
+
function _ts_metadata7(k, v) {
|
|
1206
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1207
|
+
}
|
|
1208
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1209
|
+
var DevApiRoutesController = class {
|
|
1210
|
+
static {
|
|
1211
|
+
__name(this, "DevApiRoutesController");
|
|
1212
|
+
}
|
|
1213
|
+
httpAdapterHost;
|
|
1214
|
+
constructor(httpAdapterHost) {
|
|
1215
|
+
this.httpAdapterHost = httpAdapterHost;
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* 获取 API 路由列表
|
|
1219
|
+
*
|
|
1220
|
+
* GET /dev/api-routes
|
|
1221
|
+
*
|
|
1222
|
+
* 返回预处理后的 API 路由数据,按模块分组
|
|
1223
|
+
*/
|
|
1224
|
+
getApiRoutes() {
|
|
1225
|
+
const routes = this.extractRoutes();
|
|
1226
|
+
const groups = this.groupRoutesByModule(routes);
|
|
1227
|
+
return {
|
|
1228
|
+
groups,
|
|
1229
|
+
total: routes.length
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* 从 Express 路由栈中提取 API 路由
|
|
1234
|
+
*/
|
|
1235
|
+
extractRoutes() {
|
|
1236
|
+
const server = this.httpAdapterHost.httpAdapter;
|
|
1237
|
+
const router = server.getInstance()._router;
|
|
1238
|
+
if (!router?.stack) {
|
|
1239
|
+
return [];
|
|
1240
|
+
}
|
|
1241
|
+
const routes = [];
|
|
1242
|
+
const seenRoutes = /* @__PURE__ */ new Set();
|
|
1243
|
+
router.stack.forEach((layer) => {
|
|
1244
|
+
if (layer.route) {
|
|
1245
|
+
const path = layer.route.path;
|
|
1246
|
+
if (!path.startsWith("/api/") || path.includes("__framework__") || path.includes("__innerapi__")) {
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
const methods = Object.keys(layer.route.methods).filter((m) => layer.route.methods[m]);
|
|
1250
|
+
methods.forEach((method) => {
|
|
1251
|
+
const upperMethod = method.toUpperCase();
|
|
1252
|
+
const routeKey = `${upperMethod}:${path}`;
|
|
1253
|
+
if (seenRoutes.has(routeKey)) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
seenRoutes.add(routeKey);
|
|
1257
|
+
const moduleId = this.extractModuleFromPath(path);
|
|
1258
|
+
const id = this.generateRouteId(upperMethod, path);
|
|
1259
|
+
routes.push({
|
|
1260
|
+
id,
|
|
1261
|
+
path,
|
|
1262
|
+
method: upperMethod,
|
|
1263
|
+
module: moduleId
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
return routes;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* 从路径中提取模块名
|
|
1272
|
+
* /api/users/... -> users
|
|
1273
|
+
* /api/v1/orders/... -> orders
|
|
1274
|
+
*/
|
|
1275
|
+
extractModuleFromPath(path) {
|
|
1276
|
+
const segments = path.split("/").filter(Boolean);
|
|
1277
|
+
let startIndex = 0;
|
|
1278
|
+
if (segments[0] === "api") {
|
|
1279
|
+
startIndex = 1;
|
|
1280
|
+
}
|
|
1281
|
+
if (segments[startIndex]?.match(/^v\d+$/)) {
|
|
1282
|
+
startIndex++;
|
|
1283
|
+
}
|
|
1284
|
+
const moduleName = segments[startIndex];
|
|
1285
|
+
if (!moduleName || moduleName.startsWith(":")) {
|
|
1286
|
+
return "default";
|
|
1287
|
+
}
|
|
1288
|
+
return moduleName;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* 生成路由唯一标识
|
|
1292
|
+
*/
|
|
1293
|
+
generateRouteId(method, path) {
|
|
1294
|
+
const cleanPath = path.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
1295
|
+
return `${method.toLowerCase()}_${cleanPath}`;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* 按模块分组路由
|
|
1299
|
+
*/
|
|
1300
|
+
groupRoutesByModule(routes) {
|
|
1301
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1302
|
+
routes.forEach((route) => {
|
|
1303
|
+
const existing = groupMap.get(route.module) || [];
|
|
1304
|
+
existing.push(route);
|
|
1305
|
+
groupMap.set(route.module, existing);
|
|
1306
|
+
});
|
|
1307
|
+
const groups = [];
|
|
1308
|
+
groupMap.forEach((apis, moduleName) => {
|
|
1309
|
+
groups.push({
|
|
1310
|
+
id: moduleName,
|
|
1311
|
+
name: this.formatModuleName(moduleName),
|
|
1312
|
+
apis: apis.sort((a, b) => a.path.localeCompare(b.path))
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
return groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* 格式化模块名用于显示
|
|
1319
|
+
*/
|
|
1320
|
+
formatModuleName(moduleName) {
|
|
1321
|
+
return moduleName.charAt(0).toUpperCase() + moduleName.slice(1);
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
_ts_decorate10([
|
|
1325
|
+
(0, import_common10.Get)(),
|
|
1326
|
+
(0, import_common10.Header)("Access-Control-Allow-Origin", "*"),
|
|
1327
|
+
(0, import_common10.Header)("Access-Control-Allow-Methods", "GET, OPTIONS"),
|
|
1328
|
+
(0, import_common10.Header)("Access-Control-Allow-Headers", "Content-Type, Accept"),
|
|
1329
|
+
_ts_metadata7("design:type", Function),
|
|
1330
|
+
_ts_metadata7("design:paramtypes", []),
|
|
1331
|
+
_ts_metadata7("design:returntype", Object)
|
|
1332
|
+
], DevApiRoutesController.prototype, "getApiRoutes", null);
|
|
1333
|
+
DevApiRoutesController = _ts_decorate10([
|
|
1334
|
+
(0, import_swagger.ApiExcludeController)(),
|
|
1335
|
+
(0, import_common10.Controller)("dev/api-routes"),
|
|
1336
|
+
_ts_metadata7("design:type", Function),
|
|
1337
|
+
_ts_metadata7("design:paramtypes", [
|
|
1338
|
+
typeof import_core2.HttpAdapterHost === "undefined" ? Object : import_core2.HttpAdapterHost
|
|
1339
|
+
])
|
|
1340
|
+
], DevApiRoutesController);
|
|
1341
|
+
|
|
1342
|
+
// src/modules/platform/module.ts
|
|
1343
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1344
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1345
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1346
|
+
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;
|
|
1347
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1348
|
+
}
|
|
1349
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1238
1350
|
var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
|
|
1239
1351
|
var PlatformModule = class _PlatformModule {
|
|
1240
1352
|
static {
|
|
@@ -1245,6 +1357,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
1245
1357
|
_PlatformModule.moduleOptions = options;
|
|
1246
1358
|
return {
|
|
1247
1359
|
module: _PlatformModule,
|
|
1360
|
+
controllers: process.env.NODE_ENV === "development" ? [
|
|
1361
|
+
DevApiRoutesController
|
|
1362
|
+
] : [],
|
|
1248
1363
|
imports: [
|
|
1249
1364
|
import_config2.ConfigModule.forRoot({
|
|
1250
1365
|
isGlobal: true,
|
|
@@ -1308,8 +1423,8 @@ var PlatformModule = class _PlatformModule {
|
|
|
1308
1423
|
useValue: options
|
|
1309
1424
|
},
|
|
1310
1425
|
{
|
|
1311
|
-
provide:
|
|
1312
|
-
useValue: new
|
|
1426
|
+
provide: import_core3.APP_PIPE,
|
|
1427
|
+
useValue: new import_common11.ValidationPipe({
|
|
1313
1428
|
transform: true,
|
|
1314
1429
|
transformOptions: {
|
|
1315
1430
|
enableImplicitConversion: true
|
|
@@ -1328,18 +1443,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
1328
1443
|
PlatformHttpClientService
|
|
1329
1444
|
]
|
|
1330
1445
|
},
|
|
1331
|
-
{
|
|
1332
|
-
provide: import_nestjs_common5.HTTP_CLIENT_FACTORY,
|
|
1333
|
-
useFactory: /* @__PURE__ */ __name((svc) => ({
|
|
1334
|
-
create: /* @__PURE__ */ __name((options2) => svc.createWithGlobalInterceptors(options2), "create")
|
|
1335
|
-
}), "useFactory"),
|
|
1336
|
-
inject: [
|
|
1337
|
-
PlatformHttpClientService
|
|
1338
|
-
]
|
|
1339
|
-
},
|
|
1340
1446
|
HttpInterceptorService,
|
|
1341
1447
|
{
|
|
1342
|
-
provide:
|
|
1448
|
+
provide: import_core3.APP_INTERCEPTOR,
|
|
1343
1449
|
useClass: import_nestjs_observable.TraceInterceptor
|
|
1344
1450
|
},
|
|
1345
1451
|
FileService
|
|
@@ -1350,8 +1456,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
1350
1456
|
import_nestjs_common5.CommonModule,
|
|
1351
1457
|
import_nestjs_common5.OBSERVABLE_SERVICE,
|
|
1352
1458
|
import_nestjs_common6.PLATFORM_HTTP_CLIENT,
|
|
1353
|
-
import_nestjs_common5.HTTP_CLIENT_FACTORY,
|
|
1354
|
-
PlatformHttpClientService,
|
|
1355
1459
|
import_nestjs_capability.CapabilityModule,
|
|
1356
1460
|
FileService
|
|
1357
1461
|
]
|
|
@@ -1382,9 +1486,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
1382
1486
|
}
|
|
1383
1487
|
}
|
|
1384
1488
|
};
|
|
1385
|
-
PlatformModule =
|
|
1386
|
-
(0,
|
|
1387
|
-
(0,
|
|
1489
|
+
PlatformModule = _ts_decorate11([
|
|
1490
|
+
(0, import_common11.Global)(),
|
|
1491
|
+
(0, import_common11.Module)({})
|
|
1388
1492
|
], PlatformModule);
|
|
1389
1493
|
|
|
1390
1494
|
// src/setup.ts
|
|
@@ -1435,7 +1539,6 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
1435
1539
|
DevToolsModule,
|
|
1436
1540
|
DevToolsV2Module,
|
|
1437
1541
|
FileService,
|
|
1438
|
-
PlatformHttpClientService,
|
|
1439
1542
|
PlatformModule,
|
|
1440
1543
|
UserContextMiddleware,
|
|
1441
1544
|
ViewContextMiddleware,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@nestjs/common';
|
|
2
|
-
import { HttpClientConfig, PlatformPluginOptions
|
|
2
|
+
import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
|
|
3
3
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
4
4
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
5
5
|
import { Request, Response, NextFunction } from 'express';
|
|
@@ -170,143 +170,28 @@ declare class FileService {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* 提供两种使用方式:
|
|
176
|
-
* 1. 全局实例:通过 `instance` 或 `PLATFORM_HTTP_CLIENT` 注入,适用于 95% 的场景
|
|
177
|
-
* 2. 独立实例:通过 `create()` 创建,适用于需要自定义拦截器或配置的场景
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* 基本使用(推荐)
|
|
181
|
-
* ```typescript
|
|
182
|
-
* @Injectable()
|
|
183
|
-
* export class UserService {
|
|
184
|
-
* constructor(
|
|
185
|
-
* @Inject(PLATFORM_HTTP_CLIENT) private http: SafeHttpClient
|
|
186
|
-
* ) {}
|
|
187
|
-
*
|
|
188
|
-
* async getUser() {
|
|
189
|
-
* return this.http.get('/user');
|
|
190
|
-
* }
|
|
191
|
-
* }
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* 需要自定义拦截器(高级场景)
|
|
196
|
-
* ```typescript
|
|
197
|
-
* @Injectable()
|
|
198
|
-
* export class FileService {
|
|
199
|
-
* private fileClient: HttpClient;
|
|
200
|
-
*
|
|
201
|
-
* constructor(private platformHttp: PlatformHttpClientService) {
|
|
202
|
-
* this.fileClient = this.platformHttp.create({
|
|
203
|
-
* config: { timeout: 60000 }
|
|
204
|
-
* });
|
|
205
|
-
*
|
|
206
|
-
* this.fileClient.interceptors.request.use((config) => {
|
|
207
|
-
* console.log('File upload starting...');
|
|
208
|
-
* return config;
|
|
209
|
-
* });
|
|
210
|
-
* }
|
|
211
|
-
* }
|
|
212
|
-
* ```
|
|
173
|
+
* API 路由信息(已处理)
|
|
213
174
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
* 如果需要自定义拦截器,请使用 `create()` 方法创建独立实例
|
|
235
|
-
*
|
|
236
|
-
* @internal
|
|
237
|
-
* @returns 原始 HttpClient 实例
|
|
238
|
-
*/
|
|
239
|
-
get rawInstance(): HttpClient;
|
|
240
|
-
/**
|
|
241
|
-
* 创建一个新的独立 HttpClient 实例
|
|
242
|
-
*
|
|
243
|
-
* 适用于需要自定义拦截器或配置的场景
|
|
244
|
-
* 创建的实例完全独立,不会影响全局实例
|
|
245
|
-
*
|
|
246
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
247
|
-
* @returns 完整的 HttpClient 实例(允许修改拦截器)
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```typescript
|
|
251
|
-
* @Injectable()
|
|
252
|
-
* export class FileService {
|
|
253
|
-
* private fileClient: HttpClient;
|
|
254
|
-
*
|
|
255
|
-
* constructor(private platformHttp: PlatformHttpClientService) {
|
|
256
|
-
* // 创建超时 60 秒的独立实例
|
|
257
|
-
* this.fileClient = this.platformHttp.create({
|
|
258
|
-
* config: { timeout: 60000 }
|
|
259
|
-
* });
|
|
260
|
-
*
|
|
261
|
-
* // 为这个实例注册拦截器(不影响全局实例)
|
|
262
|
-
* this.fileClient.interceptors.request.use((config) => {
|
|
263
|
-
* console.log('File upload starting...');
|
|
264
|
-
* return config;
|
|
265
|
-
* });
|
|
266
|
-
* }
|
|
267
|
-
*
|
|
268
|
-
* async uploadFile(file: Buffer) {
|
|
269
|
-
* return this.fileClient.post('/file/upload', file);
|
|
270
|
-
* }
|
|
271
|
-
* }
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
create(options?: PlatformHttpClientOptions): HttpClient;
|
|
275
|
-
/**
|
|
276
|
-
* 创建一个带全局拦截器的独立 HttpClient 实例
|
|
277
|
-
*
|
|
278
|
-
* 与 `create()` 类似,但会自动注册全局拦截器(日志、x-tt-env 透传等)
|
|
279
|
-
* 适用于需要保留平台标准行为,同时又需要添加自定义拦截器的场景
|
|
280
|
-
*
|
|
281
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
282
|
-
* @returns 完整的 HttpClient 实例(带全局拦截器,允许添加更多拦截器)
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```typescript
|
|
286
|
-
* const client = this.platformHttp.createWithGlobalInterceptors();
|
|
287
|
-
* // 客户端已包含日志和 x-tt-env 拦截器
|
|
288
|
-
* // 可以继续添加自定义拦截器
|
|
289
|
-
* client.interceptors.request.use((config) => {
|
|
290
|
-
* config.headers['x-custom'] = 'value';
|
|
291
|
-
* return config;
|
|
292
|
-
* });
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
createWithGlobalInterceptors(options?: PlatformHttpClientOptions): HttpClient;
|
|
296
|
-
/**
|
|
297
|
-
* 注册全局拦截器(用于单例实例)
|
|
298
|
-
*/
|
|
299
|
-
private registerGlobalInterceptors;
|
|
300
|
-
/**
|
|
301
|
-
* 为指定的 HttpClient 实例注册标准拦截器
|
|
302
|
-
*
|
|
303
|
-
* 包含:
|
|
304
|
-
* - 请求日志记录
|
|
305
|
-
* - x-tt-env header 透传
|
|
306
|
-
* - 响应日志记录
|
|
307
|
-
* - 错误日志记录
|
|
308
|
-
*/
|
|
309
|
-
private registerInterceptorsForClient;
|
|
175
|
+
interface ApiRouteInfo {
|
|
176
|
+
/** 唯一标识 */
|
|
177
|
+
id: string;
|
|
178
|
+
/** 路由路径 */
|
|
179
|
+
path: string;
|
|
180
|
+
/** HTTP 方法 */
|
|
181
|
+
method: string;
|
|
182
|
+
/** 所属模块(从路径提取) */
|
|
183
|
+
module: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* API 路由分组
|
|
187
|
+
*/
|
|
188
|
+
interface ApiRouteGroup {
|
|
189
|
+
/** 分组 ID */
|
|
190
|
+
id: string;
|
|
191
|
+
/** 分组名称 */
|
|
192
|
+
name: string;
|
|
193
|
+
/** 该分组下的 API 列表 */
|
|
194
|
+
apis: ApiRouteInfo[];
|
|
310
195
|
}
|
|
311
196
|
|
|
312
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, type PlatformHttpClientOptions,
|
|
197
|
+
export { type ApiNotFoundResponse, type ApiRouteGroup, type ApiRouteInfo, CsrfMiddleware, CsrfTokenMiddleware, FileService, type PlatformHttpClientOptions, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@nestjs/common';
|
|
2
|
-
import { HttpClientConfig, PlatformPluginOptions
|
|
2
|
+
import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
|
|
3
3
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
4
4
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
5
5
|
import { Request, Response, NextFunction } from 'express';
|
|
@@ -170,143 +170,28 @@ declare class FileService {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* 提供两种使用方式:
|
|
176
|
-
* 1. 全局实例:通过 `instance` 或 `PLATFORM_HTTP_CLIENT` 注入,适用于 95% 的场景
|
|
177
|
-
* 2. 独立实例:通过 `create()` 创建,适用于需要自定义拦截器或配置的场景
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* 基本使用(推荐)
|
|
181
|
-
* ```typescript
|
|
182
|
-
* @Injectable()
|
|
183
|
-
* export class UserService {
|
|
184
|
-
* constructor(
|
|
185
|
-
* @Inject(PLATFORM_HTTP_CLIENT) private http: SafeHttpClient
|
|
186
|
-
* ) {}
|
|
187
|
-
*
|
|
188
|
-
* async getUser() {
|
|
189
|
-
* return this.http.get('/user');
|
|
190
|
-
* }
|
|
191
|
-
* }
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* 需要自定义拦截器(高级场景)
|
|
196
|
-
* ```typescript
|
|
197
|
-
* @Injectable()
|
|
198
|
-
* export class FileService {
|
|
199
|
-
* private fileClient: HttpClient;
|
|
200
|
-
*
|
|
201
|
-
* constructor(private platformHttp: PlatformHttpClientService) {
|
|
202
|
-
* this.fileClient = this.platformHttp.create({
|
|
203
|
-
* config: { timeout: 60000 }
|
|
204
|
-
* });
|
|
205
|
-
*
|
|
206
|
-
* this.fileClient.interceptors.request.use((config) => {
|
|
207
|
-
* console.log('File upload starting...');
|
|
208
|
-
* return config;
|
|
209
|
-
* });
|
|
210
|
-
* }
|
|
211
|
-
* }
|
|
212
|
-
* ```
|
|
173
|
+
* API 路由信息(已处理)
|
|
213
174
|
*/
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
* 如果需要自定义拦截器,请使用 `create()` 方法创建独立实例
|
|
235
|
-
*
|
|
236
|
-
* @internal
|
|
237
|
-
* @returns 原始 HttpClient 实例
|
|
238
|
-
*/
|
|
239
|
-
get rawInstance(): HttpClient;
|
|
240
|
-
/**
|
|
241
|
-
* 创建一个新的独立 HttpClient 实例
|
|
242
|
-
*
|
|
243
|
-
* 适用于需要自定义拦截器或配置的场景
|
|
244
|
-
* 创建的实例完全独立,不会影响全局实例
|
|
245
|
-
*
|
|
246
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
247
|
-
* @returns 完整的 HttpClient 实例(允许修改拦截器)
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```typescript
|
|
251
|
-
* @Injectable()
|
|
252
|
-
* export class FileService {
|
|
253
|
-
* private fileClient: HttpClient;
|
|
254
|
-
*
|
|
255
|
-
* constructor(private platformHttp: PlatformHttpClientService) {
|
|
256
|
-
* // 创建超时 60 秒的独立实例
|
|
257
|
-
* this.fileClient = this.platformHttp.create({
|
|
258
|
-
* config: { timeout: 60000 }
|
|
259
|
-
* });
|
|
260
|
-
*
|
|
261
|
-
* // 为这个实例注册拦截器(不影响全局实例)
|
|
262
|
-
* this.fileClient.interceptors.request.use((config) => {
|
|
263
|
-
* console.log('File upload starting...');
|
|
264
|
-
* return config;
|
|
265
|
-
* });
|
|
266
|
-
* }
|
|
267
|
-
*
|
|
268
|
-
* async uploadFile(file: Buffer) {
|
|
269
|
-
* return this.fileClient.post('/file/upload', file);
|
|
270
|
-
* }
|
|
271
|
-
* }
|
|
272
|
-
* ```
|
|
273
|
-
*/
|
|
274
|
-
create(options?: PlatformHttpClientOptions): HttpClient;
|
|
275
|
-
/**
|
|
276
|
-
* 创建一个带全局拦截器的独立 HttpClient 实例
|
|
277
|
-
*
|
|
278
|
-
* 与 `create()` 类似,但会自动注册全局拦截器(日志、x-tt-env 透传等)
|
|
279
|
-
* 适用于需要保留平台标准行为,同时又需要添加自定义拦截器的场景
|
|
280
|
-
*
|
|
281
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
282
|
-
* @returns 完整的 HttpClient 实例(带全局拦截器,允许添加更多拦截器)
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```typescript
|
|
286
|
-
* const client = this.platformHttp.createWithGlobalInterceptors();
|
|
287
|
-
* // 客户端已包含日志和 x-tt-env 拦截器
|
|
288
|
-
* // 可以继续添加自定义拦截器
|
|
289
|
-
* client.interceptors.request.use((config) => {
|
|
290
|
-
* config.headers['x-custom'] = 'value';
|
|
291
|
-
* return config;
|
|
292
|
-
* });
|
|
293
|
-
* ```
|
|
294
|
-
*/
|
|
295
|
-
createWithGlobalInterceptors(options?: PlatformHttpClientOptions): HttpClient;
|
|
296
|
-
/**
|
|
297
|
-
* 注册全局拦截器(用于单例实例)
|
|
298
|
-
*/
|
|
299
|
-
private registerGlobalInterceptors;
|
|
300
|
-
/**
|
|
301
|
-
* 为指定的 HttpClient 实例注册标准拦截器
|
|
302
|
-
*
|
|
303
|
-
* 包含:
|
|
304
|
-
* - 请求日志记录
|
|
305
|
-
* - x-tt-env header 透传
|
|
306
|
-
* - 响应日志记录
|
|
307
|
-
* - 错误日志记录
|
|
308
|
-
*/
|
|
309
|
-
private registerInterceptorsForClient;
|
|
175
|
+
interface ApiRouteInfo {
|
|
176
|
+
/** 唯一标识 */
|
|
177
|
+
id: string;
|
|
178
|
+
/** 路由路径 */
|
|
179
|
+
path: string;
|
|
180
|
+
/** HTTP 方法 */
|
|
181
|
+
method: string;
|
|
182
|
+
/** 所属模块(从路径提取) */
|
|
183
|
+
module: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* API 路由分组
|
|
187
|
+
*/
|
|
188
|
+
interface ApiRouteGroup {
|
|
189
|
+
/** 分组 ID */
|
|
190
|
+
id: string;
|
|
191
|
+
/** 分组名称 */
|
|
192
|
+
name: string;
|
|
193
|
+
/** 该分组下的 API 列表 */
|
|
194
|
+
apis: ApiRouteInfo[];
|
|
310
195
|
}
|
|
311
196
|
|
|
312
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, type PlatformHttpClientOptions,
|
|
197
|
+
export { type ApiNotFoundResponse, type ApiRouteGroup, type ApiRouteInfo, CsrfMiddleware, CsrfTokenMiddleware, FileService, type PlatformHttpClientOptions, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4
4
|
// src/modules/platform/module.ts
|
|
5
5
|
import { Global, Module, ValidationPipe } from "@nestjs/common";
|
|
6
6
|
import { APP_INTERCEPTOR, APP_PIPE } from "@nestjs/core";
|
|
7
|
-
import { CommonModule, OBSERVABLE_SERVICE as OBSERVABLE_SERVICE2
|
|
7
|
+
import { CommonModule, OBSERVABLE_SERVICE as OBSERVABLE_SERVICE2 } from "@lark-apaas/nestjs-common";
|
|
8
8
|
import { ConfigModule, ConfigService } from "@nestjs/config";
|
|
9
9
|
import { NestjsObservableModule as ObservableModule, Observable, ObservableTraceMiddleware, TraceInterceptor } from "@lark-apaas/nestjs-observable";
|
|
10
10
|
import { HttpModule } from "@nestjs/axios";
|
|
@@ -714,47 +714,10 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
716
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
* 与 `create()` 类似,但会自动注册全局拦截器(日志、x-tt-env 透传等)
|
|
720
|
-
* 适用于需要保留平台标准行为,同时又需要添加自定义拦截器的场景
|
|
721
|
-
*
|
|
722
|
-
* @param options - 配置选项(会与全局配置合并)
|
|
723
|
-
* @returns 完整的 HttpClient 实例(带全局拦截器,允许添加更多拦截器)
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* ```typescript
|
|
727
|
-
* const client = this.platformHttp.createWithGlobalInterceptors();
|
|
728
|
-
* // 客户端已包含日志和 x-tt-env 拦截器
|
|
729
|
-
* // 可以继续添加自定义拦截器
|
|
730
|
-
* client.interceptors.request.use((config) => {
|
|
731
|
-
* config.headers['x-custom'] = 'value';
|
|
732
|
-
* return config;
|
|
733
|
-
* });
|
|
734
|
-
* ```
|
|
735
|
-
*/
|
|
736
|
-
createWithGlobalInterceptors(options) {
|
|
737
|
-
const client = this.create(options);
|
|
738
|
-
this.registerInterceptorsForClient(client);
|
|
739
|
-
return client;
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* 注册全局拦截器(用于单例实例)
|
|
717
|
+
* 注册全局拦截器
|
|
743
718
|
*/
|
|
744
719
|
registerGlobalInterceptors() {
|
|
745
|
-
this.
|
|
746
|
-
}
|
|
747
|
-
/**
|
|
748
|
-
* 为指定的 HttpClient 实例注册标准拦截器
|
|
749
|
-
*
|
|
750
|
-
* 包含:
|
|
751
|
-
* - 请求日志记录
|
|
752
|
-
* - x-tt-env header 透传
|
|
753
|
-
* - 响应日志记录
|
|
754
|
-
* - 错误日志记录
|
|
755
|
-
*/
|
|
756
|
-
registerInterceptorsForClient(client) {
|
|
757
|
-
client.interceptors.request.use((config) => {
|
|
720
|
+
this.client.interceptors.request.use((config) => {
|
|
758
721
|
this.logger.debug(`Server SDK HTTP Request: ${config.method?.toUpperCase()} ${config.url}`);
|
|
759
722
|
const ttEnv = this.requestContext.get("ttEnv");
|
|
760
723
|
if (ttEnv) {
|
|
@@ -768,7 +731,7 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
768
731
|
this.logger.error("Server SDK HTTP Request Error", error, "HttpService");
|
|
769
732
|
return Promise.reject(error);
|
|
770
733
|
});
|
|
771
|
-
client.interceptors.response.use((response) => {
|
|
734
|
+
this.client.interceptors.response.use((response) => {
|
|
772
735
|
this.logger.debug(`Server SDK HTTP Response: ${response.status} ${response.url}`);
|
|
773
736
|
return response;
|
|
774
737
|
}, (error) => {
|
|
@@ -1182,6 +1145,11 @@ FileService = _ts_decorate9([
|
|
|
1182
1145
|
|
|
1183
1146
|
// src/modules/platform/module.ts
|
|
1184
1147
|
import { AuthZPaasModule } from "@lark-apaas/nestjs-authzpaas";
|
|
1148
|
+
|
|
1149
|
+
// src/controllers/dev-api-routes.controller.ts
|
|
1150
|
+
import { Controller, Get, Header } from "@nestjs/common";
|
|
1151
|
+
import { HttpAdapterHost as HttpAdapterHost2 } from "@nestjs/core";
|
|
1152
|
+
import { ApiExcludeController } from "@nestjs/swagger";
|
|
1185
1153
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1186
1154
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1187
1155
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1189,6 +1157,151 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
1189
1157
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1190
1158
|
}
|
|
1191
1159
|
__name(_ts_decorate10, "_ts_decorate");
|
|
1160
|
+
function _ts_metadata7(k, v) {
|
|
1161
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1162
|
+
}
|
|
1163
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
1164
|
+
var DevApiRoutesController = class {
|
|
1165
|
+
static {
|
|
1166
|
+
__name(this, "DevApiRoutesController");
|
|
1167
|
+
}
|
|
1168
|
+
httpAdapterHost;
|
|
1169
|
+
constructor(httpAdapterHost) {
|
|
1170
|
+
this.httpAdapterHost = httpAdapterHost;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* 获取 API 路由列表
|
|
1174
|
+
*
|
|
1175
|
+
* GET /dev/api-routes
|
|
1176
|
+
*
|
|
1177
|
+
* 返回预处理后的 API 路由数据,按模块分组
|
|
1178
|
+
*/
|
|
1179
|
+
getApiRoutes() {
|
|
1180
|
+
const routes = this.extractRoutes();
|
|
1181
|
+
const groups = this.groupRoutesByModule(routes);
|
|
1182
|
+
return {
|
|
1183
|
+
groups,
|
|
1184
|
+
total: routes.length
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* 从 Express 路由栈中提取 API 路由
|
|
1189
|
+
*/
|
|
1190
|
+
extractRoutes() {
|
|
1191
|
+
const server = this.httpAdapterHost.httpAdapter;
|
|
1192
|
+
const router = server.getInstance()._router;
|
|
1193
|
+
if (!router?.stack) {
|
|
1194
|
+
return [];
|
|
1195
|
+
}
|
|
1196
|
+
const routes = [];
|
|
1197
|
+
const seenRoutes = /* @__PURE__ */ new Set();
|
|
1198
|
+
router.stack.forEach((layer) => {
|
|
1199
|
+
if (layer.route) {
|
|
1200
|
+
const path = layer.route.path;
|
|
1201
|
+
if (!path.startsWith("/api/") || path.includes("__framework__") || path.includes("__innerapi__")) {
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
const methods = Object.keys(layer.route.methods).filter((m) => layer.route.methods[m]);
|
|
1205
|
+
methods.forEach((method) => {
|
|
1206
|
+
const upperMethod = method.toUpperCase();
|
|
1207
|
+
const routeKey = `${upperMethod}:${path}`;
|
|
1208
|
+
if (seenRoutes.has(routeKey)) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
seenRoutes.add(routeKey);
|
|
1212
|
+
const moduleId = this.extractModuleFromPath(path);
|
|
1213
|
+
const id = this.generateRouteId(upperMethod, path);
|
|
1214
|
+
routes.push({
|
|
1215
|
+
id,
|
|
1216
|
+
path,
|
|
1217
|
+
method: upperMethod,
|
|
1218
|
+
module: moduleId
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
return routes;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* 从路径中提取模块名
|
|
1227
|
+
* /api/users/... -> users
|
|
1228
|
+
* /api/v1/orders/... -> orders
|
|
1229
|
+
*/
|
|
1230
|
+
extractModuleFromPath(path) {
|
|
1231
|
+
const segments = path.split("/").filter(Boolean);
|
|
1232
|
+
let startIndex = 0;
|
|
1233
|
+
if (segments[0] === "api") {
|
|
1234
|
+
startIndex = 1;
|
|
1235
|
+
}
|
|
1236
|
+
if (segments[startIndex]?.match(/^v\d+$/)) {
|
|
1237
|
+
startIndex++;
|
|
1238
|
+
}
|
|
1239
|
+
const moduleName = segments[startIndex];
|
|
1240
|
+
if (!moduleName || moduleName.startsWith(":")) {
|
|
1241
|
+
return "default";
|
|
1242
|
+
}
|
|
1243
|
+
return moduleName;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* 生成路由唯一标识
|
|
1247
|
+
*/
|
|
1248
|
+
generateRouteId(method, path) {
|
|
1249
|
+
const cleanPath = path.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
|
|
1250
|
+
return `${method.toLowerCase()}_${cleanPath}`;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* 按模块分组路由
|
|
1254
|
+
*/
|
|
1255
|
+
groupRoutesByModule(routes) {
|
|
1256
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
1257
|
+
routes.forEach((route) => {
|
|
1258
|
+
const existing = groupMap.get(route.module) || [];
|
|
1259
|
+
existing.push(route);
|
|
1260
|
+
groupMap.set(route.module, existing);
|
|
1261
|
+
});
|
|
1262
|
+
const groups = [];
|
|
1263
|
+
groupMap.forEach((apis, moduleName) => {
|
|
1264
|
+
groups.push({
|
|
1265
|
+
id: moduleName,
|
|
1266
|
+
name: this.formatModuleName(moduleName),
|
|
1267
|
+
apis: apis.sort((a, b) => a.path.localeCompare(b.path))
|
|
1268
|
+
});
|
|
1269
|
+
});
|
|
1270
|
+
return groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* 格式化模块名用于显示
|
|
1274
|
+
*/
|
|
1275
|
+
formatModuleName(moduleName) {
|
|
1276
|
+
return moduleName.charAt(0).toUpperCase() + moduleName.slice(1);
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
_ts_decorate10([
|
|
1280
|
+
Get(),
|
|
1281
|
+
Header("Access-Control-Allow-Origin", "*"),
|
|
1282
|
+
Header("Access-Control-Allow-Methods", "GET, OPTIONS"),
|
|
1283
|
+
Header("Access-Control-Allow-Headers", "Content-Type, Accept"),
|
|
1284
|
+
_ts_metadata7("design:type", Function),
|
|
1285
|
+
_ts_metadata7("design:paramtypes", []),
|
|
1286
|
+
_ts_metadata7("design:returntype", Object)
|
|
1287
|
+
], DevApiRoutesController.prototype, "getApiRoutes", null);
|
|
1288
|
+
DevApiRoutesController = _ts_decorate10([
|
|
1289
|
+
ApiExcludeController(),
|
|
1290
|
+
Controller("dev/api-routes"),
|
|
1291
|
+
_ts_metadata7("design:type", Function),
|
|
1292
|
+
_ts_metadata7("design:paramtypes", [
|
|
1293
|
+
typeof HttpAdapterHost2 === "undefined" ? Object : HttpAdapterHost2
|
|
1294
|
+
])
|
|
1295
|
+
], DevApiRoutesController);
|
|
1296
|
+
|
|
1297
|
+
// src/modules/platform/module.ts
|
|
1298
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1299
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1300
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1301
|
+
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;
|
|
1302
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1303
|
+
}
|
|
1304
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1192
1305
|
var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
|
|
1193
1306
|
var PlatformModule = class _PlatformModule {
|
|
1194
1307
|
static {
|
|
@@ -1199,6 +1312,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
1199
1312
|
_PlatformModule.moduleOptions = options;
|
|
1200
1313
|
return {
|
|
1201
1314
|
module: _PlatformModule,
|
|
1315
|
+
controllers: process.env.NODE_ENV === "development" ? [
|
|
1316
|
+
DevApiRoutesController
|
|
1317
|
+
] : [],
|
|
1202
1318
|
imports: [
|
|
1203
1319
|
ConfigModule.forRoot({
|
|
1204
1320
|
isGlobal: true,
|
|
@@ -1282,15 +1398,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
1282
1398
|
PlatformHttpClientService
|
|
1283
1399
|
]
|
|
1284
1400
|
},
|
|
1285
|
-
{
|
|
1286
|
-
provide: HTTP_CLIENT_FACTORY,
|
|
1287
|
-
useFactory: /* @__PURE__ */ __name((svc) => ({
|
|
1288
|
-
create: /* @__PURE__ */ __name((options2) => svc.createWithGlobalInterceptors(options2), "create")
|
|
1289
|
-
}), "useFactory"),
|
|
1290
|
-
inject: [
|
|
1291
|
-
PlatformHttpClientService
|
|
1292
|
-
]
|
|
1293
|
-
},
|
|
1294
1401
|
HttpInterceptorService,
|
|
1295
1402
|
{
|
|
1296
1403
|
provide: APP_INTERCEPTOR,
|
|
@@ -1304,8 +1411,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
1304
1411
|
CommonModule,
|
|
1305
1412
|
OBSERVABLE_SERVICE2,
|
|
1306
1413
|
PLATFORM_HTTP_CLIENT3,
|
|
1307
|
-
HTTP_CLIENT_FACTORY,
|
|
1308
|
-
PlatformHttpClientService,
|
|
1309
1414
|
CapabilityModule,
|
|
1310
1415
|
FileService
|
|
1311
1416
|
]
|
|
@@ -1336,7 +1441,7 @@ var PlatformModule = class _PlatformModule {
|
|
|
1336
1441
|
}
|
|
1337
1442
|
}
|
|
1338
1443
|
};
|
|
1339
|
-
PlatformModule =
|
|
1444
|
+
PlatformModule = _ts_decorate11([
|
|
1340
1445
|
Global(),
|
|
1341
1446
|
Module({})
|
|
1342
1447
|
], PlatformModule);
|
|
@@ -1388,7 +1493,6 @@ export {
|
|
|
1388
1493
|
DevToolsModule,
|
|
1389
1494
|
DevToolsV2Module2 as DevToolsV2Module,
|
|
1390
1495
|
FileService,
|
|
1391
|
-
PlatformHttpClientService,
|
|
1392
1496
|
PlatformModule,
|
|
1393
1497
|
UserContextMiddleware,
|
|
1394
1498
|
ViewContextMiddleware,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.23-alpha.
|
|
3
|
+
"version": "1.1.23-alpha.7",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@lark-apaas/file-service": "^0.1.1",
|
|
43
43
|
"@lark-apaas/http-client": "^0.1.2",
|
|
44
44
|
"@lark-apaas/nestjs-authnpaas": "^1.0.2",
|
|
45
|
-
"@lark-apaas/nestjs-authzpaas": "0.1.
|
|
46
|
-
"@lark-apaas/nestjs-capability": "0.1.
|
|
47
|
-
"@lark-apaas/nestjs-common": "0.1.
|
|
48
|
-
"@lark-apaas/nestjs-datapaas": "1.0.
|
|
49
|
-
"@lark-apaas/nestjs-logger": "1.0.10-alpha.
|
|
50
|
-
"@lark-apaas/nestjs-observable": "0.0.
|
|
45
|
+
"@lark-apaas/nestjs-authzpaas": "^0.1.1",
|
|
46
|
+
"@lark-apaas/nestjs-capability": "^0.1.3",
|
|
47
|
+
"@lark-apaas/nestjs-common": "^0.1.3",
|
|
48
|
+
"@lark-apaas/nestjs-datapaas": "^1.0.9",
|
|
49
|
+
"@lark-apaas/nestjs-logger": "1.0.10-alpha.6",
|
|
50
|
+
"@lark-apaas/nestjs-observable": "^0.0.4",
|
|
51
51
|
"@lark-apaas/nestjs-openapi-devtools": "^1.0.9",
|
|
52
52
|
"@lark-apaas/nestjs-trigger": "^0.0.2",
|
|
53
53
|
"@nestjs/axios": "^4.0.1",
|