midway-fatcms 0.0.1-beta.29 → 0.0.1-beta.30
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/.eslintrc.json +14 -14
- package/.prettierrc.js +4 -4
- package/README.md +8 -8
- package/index.d.ts +10 -10
- package/package.json +76 -76
- package/tsconfig.json +32 -32
- package/dist/config/config.default.d.ts +0 -3
- package/dist/config/config.default.js +0 -189
- package/dist/config/seed/aeskey.txt +0 -1
- package/dist/config/utils.d.ts +0 -1
- package/dist/config/utils.js +0 -23
- package/dist/configuration.d.ts +0 -7
- package/dist/configuration.js +0 -113
- package/dist/controller/base/BaseApiController.d.ts +0 -37
- package/dist/controller/base/BaseApiController.js +0 -164
- package/dist/controller/gateway/AnyApiGatewayController.d.ts +0 -13
- package/dist/controller/gateway/AnyApiGatewayController.js +0 -55
- package/dist/controller/gateway/AsyncTaskController.d.ts +0 -20
- package/dist/controller/gateway/AsyncTaskController.js +0 -181
- package/dist/controller/gateway/CrudMtdGatewayController.d.ts +0 -21
- package/dist/controller/gateway/CrudMtdGatewayController.js +0 -119
- package/dist/controller/gateway/CrudStdGatewayController.d.ts +0 -38
- package/dist/controller/gateway/CrudStdGatewayController.js +0 -137
- package/dist/controller/gateway/DocGatewayController.d.ts +0 -27
- package/dist/controller/gateway/DocGatewayController.js +0 -179
- package/dist/controller/gateway/FileController.d.ts +0 -25
- package/dist/controller/gateway/FileController.js +0 -129
- package/dist/controller/gateway/ProxyApiGatewayController.d.ts +0 -18
- package/dist/controller/gateway/ProxyApiGatewayController.js +0 -78
- package/dist/controller/gateway/PublicApiController.d.ts +0 -27
- package/dist/controller/gateway/PublicApiController.js +0 -165
- package/dist/controller/gateway/StaticController.d.ts +0 -24
- package/dist/controller/gateway/StaticController.js +0 -288
- package/dist/controller/helpers.controller.d.ts +0 -39
- package/dist/controller/helpers.controller.js +0 -188
- package/dist/controller/home.controller.d.ts +0 -9
- package/dist/controller/home.controller.js +0 -72
- package/dist/controller/manage/AnyApiMangeApi.d.ts +0 -10
- package/dist/controller/manage/AnyApiMangeApi.js +0 -98
- package/dist/controller/manage/AppLogMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppLogMangeApi.js +0 -88
- package/dist/controller/manage/AppMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppMangeApi.js +0 -88
- package/dist/controller/manage/AppPageMangeApi.d.ts +0 -10
- package/dist/controller/manage/AppPageMangeApi.js +0 -87
- package/dist/controller/manage/AppSchemaHistoryApi.d.ts +0 -10
- package/dist/controller/manage/AppSchemaHistoryApi.js +0 -83
- package/dist/controller/manage/CrudMethodsMangeApi.d.ts +0 -10
- package/dist/controller/manage/CrudMethodsMangeApi.js +0 -84
- package/dist/controller/manage/CrudStandardDesignApi.d.ts +0 -38
- package/dist/controller/manage/CrudStandardDesignApi.js +0 -342
- package/dist/controller/manage/DataDictManageApi.d.ts +0 -15
- package/dist/controller/manage/DataDictManageApi.js +0 -133
- package/dist/controller/manage/DeployManageApi.d.ts +0 -19
- package/dist/controller/manage/DeployManageApi.js +0 -180
- package/dist/controller/manage/DocLibManageApi.d.ts +0 -10
- package/dist/controller/manage/DocLibManageApi.js +0 -104
- package/dist/controller/manage/DocManageApi.d.ts +0 -11
- package/dist/controller/manage/DocManageApi.js +0 -130
- package/dist/controller/manage/FileManageApi.d.ts +0 -13
- package/dist/controller/manage/FileManageApi.js +0 -77
- package/dist/controller/manage/LowCodeTplManageApi.d.ts +0 -13
- package/dist/controller/manage/LowCodeTplManageApi.js +0 -86
- package/dist/controller/manage/MenuManageApi.d.ts +0 -10
- package/dist/controller/manage/MenuManageApi.js +0 -93
- package/dist/controller/manage/ProxyApiMangeApi.d.ts +0 -10
- package/dist/controller/manage/ProxyApiMangeApi.js +0 -87
- package/dist/controller/manage/SuperAdminManageApi.d.ts +0 -24
- package/dist/controller/manage/SuperAdminManageApi.js +0 -153
- package/dist/controller/manage/SysConfigMangeApi.d.ts +0 -11
- package/dist/controller/manage/SysConfigMangeApi.js +0 -126
- package/dist/controller/manage/SystemInfoManageApi.d.ts +0 -12
- package/dist/controller/manage/SystemInfoManageApi.js +0 -72
- package/dist/controller/manage/UserAccountManageApi.d.ts +0 -14
- package/dist/controller/manage/UserAccountManageApi.js +0 -129
- package/dist/controller/manage/WorkbenchMangeApi.d.ts +0 -11
- package/dist/controller/manage/WorkbenchMangeApi.js +0 -103
- package/dist/controller/myinfo/AuthController.d.ts +0 -33
- package/dist/controller/myinfo/AuthController.js +0 -136
- package/dist/controller/myinfo/MyInfoController.d.ts +0 -13
- package/dist/controller/myinfo/MyInfoController.js +0 -51
- package/dist/controller/render/AppRenderController.d.ts +0 -11
- package/dist/controller/render/AppRenderController.js +0 -92
- package/dist/controller/test.controller.d.ts +0 -8
- package/dist/controller/test.controller.js +0 -51
- package/dist/filter/default.filter.d.ts +0 -7
- package/dist/filter/default.filter.js +0 -23
- package/dist/filter/notfound.filter.d.ts +0 -5
- package/dist/filter/notfound.filter.js +0 -20
- package/dist/index.d.ts +0 -102
- package/dist/index.js +0 -120
- package/dist/interface.d.ts +0 -27
- package/dist/interface.js +0 -3
- package/dist/libs/crud-pro/CrudPro.d.ts +0 -37
- package/dist/libs/crud-pro/CrudPro.js +0 -136
- package/dist/libs/crud-pro/defaultConfigs.d.ts +0 -4
- package/dist/libs/crud-pro/defaultConfigs.js +0 -15
- package/dist/libs/crud-pro/exceptions.d.ts +0 -104
- package/dist/libs/crud-pro/exceptions.js +0 -117
- package/dist/libs/crud-pro/interfaces.d.ts +0 -163
- package/dist/libs/crud-pro/interfaces.js +0 -12
- package/dist/libs/crud-pro/models/ExecuteContext.d.ts +0 -49
- package/dist/libs/crud-pro/models/ExecuteContext.js +0 -79
- package/dist/libs/crud-pro/models/ExecuteContextFunc.d.ts +0 -38
- package/dist/libs/crud-pro/models/ExecuteContextFunc.js +0 -72
- package/dist/libs/crud-pro/models/FuncContext.d.ts +0 -18
- package/dist/libs/crud-pro/models/FuncContext.js +0 -6
- package/dist/libs/crud-pro/models/RequestCfgModel.d.ts +0 -65
- package/dist/libs/crud-pro/models/RequestCfgModel.js +0 -81
- package/dist/libs/crud-pro/models/RequestModel.d.ts +0 -25
- package/dist/libs/crud-pro/models/RequestModel.js +0 -113
- package/dist/libs/crud-pro/models/ResModel.d.ts +0 -16
- package/dist/libs/crud-pro/models/ResModel.js +0 -2
- package/dist/libs/crud-pro/models/ServiceHub.d.ts +0 -20
- package/dist/libs/crud-pro/models/ServiceHub.js +0 -2
- package/dist/libs/crud-pro/models/SqlCfgModel.d.ts +0 -22
- package/dist/libs/crud-pro/models/SqlCfgModel.js +0 -40
- package/dist/libs/crud-pro/models/SqlSegArg.d.ts +0 -6
- package/dist/libs/crud-pro/models/SqlSegArg.js +0 -12
- package/dist/libs/crud-pro/models/Transaction.d.ts +0 -29
- package/dist/libs/crud-pro/models/Transaction.js +0 -67
- package/dist/libs/crud-pro/models/TransactionMySQL.d.ts +0 -28
- package/dist/libs/crud-pro/models/TransactionMySQL.js +0 -76
- package/dist/libs/crud-pro/models/TransactionPostgres.d.ts +0 -28
- package/dist/libs/crud-pro/models/TransactionPostgres.js +0 -85
- package/dist/libs/crud-pro/models/TransactionSqlServer.d.ts +0 -34
- package/dist/libs/crud-pro/models/TransactionSqlServer.js +0 -92
- package/dist/libs/crud-pro/models/keys.d.ts +0 -106
- package/dist/libs/crud-pro/models/keys.js +0 -149
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.d.ts +0 -11
- package/dist/libs/crud-pro/services/CrudProCachedCfgService.js +0 -73
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.d.ts +0 -9
- package/dist/libs/crud-pro/services/CrudProExecuteFuncService.js +0 -112
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.d.ts +0 -17
- package/dist/libs/crud-pro/services/CrudProExecuteSqlService.js +0 -225
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.d.ts +0 -9
- package/dist/libs/crud-pro/services/CrudProFieldUpdateService.js +0 -51
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.d.ts +0 -13
- package/dist/libs/crud-pro/services/CrudProFieldValidateService.js +0 -148
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.d.ts +0 -24
- package/dist/libs/crud-pro/services/CrudProGenSqlCondition.js +0 -340
- package/dist/libs/crud-pro/services/CrudProGenSqlService.d.ts +0 -25
- package/dist/libs/crud-pro/services/CrudProGenSqlService.js +0 -165
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.d.ts +0 -32
- package/dist/libs/crud-pro/services/CrudProOriginToExecuteSql.js +0 -334
- package/dist/libs/crud-pro/services/CrudProServiceBase.d.ts +0 -24
- package/dist/libs/crud-pro/services/CrudProServiceBase.js +0 -79
- package/dist/libs/crud-pro/services/CrudProTableMetaService.d.ts +0 -9
- package/dist/libs/crud-pro/services/CrudProTableMetaService.js +0 -78
- package/dist/libs/crud-pro/services/CurdProServiceHub.d.ts +0 -32
- package/dist/libs/crud-pro/services/CurdProServiceHub.js +0 -64
- package/dist/libs/crud-pro/sql.txt +0 -120
- package/dist/libs/crud-pro/utils/CompareUtils.d.ts +0 -9
- package/dist/libs/crud-pro/utils/CompareUtils.js +0 -25
- package/dist/libs/crud-pro/utils/DatabaseName.d.ts +0 -9
- package/dist/libs/crud-pro/utils/DatabaseName.js +0 -50
- package/dist/libs/crud-pro/utils/DateTimeUtils.d.ts +0 -7
- package/dist/libs/crud-pro/utils/DateTimeUtils.js +0 -21
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.d.ts +0 -19
- package/dist/libs/crud-pro/utils/MemoryRefreshCache.js +0 -47
- package/dist/libs/crud-pro/utils/MessageParseUtils.d.ts +0 -5
- package/dist/libs/crud-pro/utils/MessageParseUtils.js +0 -33
- package/dist/libs/crud-pro/utils/MixinUtils.d.ts +0 -39
- package/dist/libs/crud-pro/utils/MixinUtils.js +0 -255
- package/dist/libs/crud-pro/utils/ModelUtils.d.ts +0 -11
- package/dist/libs/crud-pro/utils/ModelUtils.js +0 -49
- package/dist/libs/crud-pro/utils/MultiKeyMap.d.ts +0 -11
- package/dist/libs/crud-pro/utils/MultiKeyMap.js +0 -63
- package/dist/libs/crud-pro/utils/SqlFuncUtils.d.ts +0 -5
- package/dist/libs/crud-pro/utils/SqlFuncUtils.js +0 -29
- package/dist/libs/crud-pro/utils/TypeUtils.d.ts +0 -40
- package/dist/libs/crud-pro/utils/TypeUtils.js +0 -166
- package/dist/libs/crud-pro/utils/ValidateUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/ValidateUtils.js +0 -165
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/MySQLUtils.js +0 -19
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/PostgresUtils.js +0 -20
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.d.ts +0 -3
- package/dist/libs/crud-pro/utils/pool/SqlServerUtils.js +0 -20
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.d.ts +0 -4
- package/dist/libs/crud-pro/utils/sqlConvert/convertColumnName.js +0 -21
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.d.ts +0 -3
- package/dist/libs/crud-pro/utils/sqlConvert/convertMix.js +0 -22
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertMsSql.js +0 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgSql.js +0 -11
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.d.ts +0 -2
- package/dist/libs/crud-pro/utils/sqlConvert/convertPgType.js +0 -128
- package/dist/libs/global-config/global-config.d.ts +0 -45
- package/dist/libs/global-config/global-config.js +0 -33
- package/dist/libs/utils/common-dto.d.ts +0 -18
- package/dist/libs/utils/common-dto.js +0 -40
- package/dist/libs/utils/crypto-utils.d.ts +0 -3
- package/dist/libs/utils/crypto-utils.js +0 -46
- package/dist/libs/utils/errorToString.d.ts +0 -2
- package/dist/libs/utils/errorToString.js +0 -57
- package/dist/libs/utils/fatcms-request.d.ts +0 -30
- package/dist/libs/utils/fatcms-request.js +0 -104
- package/dist/libs/utils/functions.d.ts +0 -5
- package/dist/libs/utils/functions.js +0 -68
- package/dist/libs/utils/ordernum-utils.d.ts +0 -2
- package/dist/libs/utils/ordernum-utils.js +0 -13
- package/dist/libs/utils/parseConfig.d.ts +0 -7
- package/dist/libs/utils/parseConfig.js +0 -44
- package/dist/libs/utils/parseCreateSql.d.ts +0 -5
- package/dist/libs/utils/parseCreateSql.js +0 -86
- package/dist/libs/utils/render-utils.d.ts +0 -28
- package/dist/libs/utils/render-utils.js +0 -135
- package/dist/middleware/forbidden.middleware.d.ts +0 -10
- package/dist/middleware/forbidden.middleware.js +0 -54
- package/dist/middleware/global.middleware.d.ts +0 -10
- package/dist/middleware/global.middleware.js +0 -266
- package/dist/middleware/permission.middleware.d.ts +0 -18
- package/dist/middleware/permission.middleware.js +0 -74
- package/dist/middleware/tx.middleware.d.ts +0 -9
- package/dist/middleware/tx.middleware.js +0 -40
- package/dist/models/AsyncTaskModel.d.ts +0 -74
- package/dist/models/AsyncTaskModel.js +0 -31
- package/dist/models/RedisKeys.d.ts +0 -14
- package/dist/models/RedisKeys.js +0 -17
- package/dist/models/SystemEntities.d.ts +0 -98
- package/dist/models/SystemEntities.js +0 -2
- package/dist/models/SystemPerm.d.ts +0 -95
- package/dist/models/SystemPerm.js +0 -100
- package/dist/models/SystemTables.d.ts +0 -25
- package/dist/models/SystemTables.js +0 -28
- package/dist/models/bizmodels.d.ts +0 -97
- package/dist/models/bizmodels.js +0 -39
- package/dist/models/contextLogger.d.ts +0 -25
- package/dist/models/contextLogger.js +0 -112
- package/dist/models/devops.d.ts +0 -12
- package/dist/models/devops.js +0 -19
- package/dist/models/userSession.d.ts +0 -61
- package/dist/models/userSession.js +0 -165
- package/dist/schedule/anonymousContext.d.ts +0 -14
- package/dist/schedule/anonymousContext.js +0 -59
- package/dist/schedule/index.d.ts +0 -4
- package/dist/schedule/index.js +0 -10
- package/dist/schedule/runSchedule.d.ts +0 -12
- package/dist/schedule/runSchedule.js +0 -68
- package/dist/schedule/scheduleNames.d.ts +0 -13
- package/dist/schedule/scheduleNames.js +0 -17
- package/dist/service/AuthService.d.ts +0 -70
- package/dist/service/AuthService.js +0 -251
- package/dist/service/EnumInfoService.d.ts +0 -30
- package/dist/service/EnumInfoService.js +0 -127
- package/dist/service/FileCenterService.d.ts +0 -43
- package/dist/service/FileCenterService.js +0 -351
- package/dist/service/SysConfigService.d.ts +0 -7
- package/dist/service/SysConfigService.js +0 -47
- package/dist/service/UserAccountService.d.ts +0 -23
- package/dist/service/UserAccountService.js +0 -107
- package/dist/service/UserSessionService.d.ts +0 -37
- package/dist/service/UserSessionService.js +0 -156
- package/dist/service/VisitStatService.d.ts +0 -14
- package/dist/service/VisitStatService.js +0 -158
- package/dist/service/WorkbenchService.d.ts +0 -52
- package/dist/service/WorkbenchService.js +0 -202
- package/dist/service/anyapi/AnyApiSandboxService.d.ts +0 -15
- package/dist/service/anyapi/AnyApiSandboxService.js +0 -122
- package/dist/service/anyapi/AnyApiService.d.ts +0 -27
- package/dist/service/anyapi/AnyApiService.js +0 -181
- package/dist/service/asyncTask/AsyncTaskRunnerService.d.ts +0 -50
- package/dist/service/asyncTask/AsyncTaskRunnerService.js +0 -287
- package/dist/service/asyncTask/AsyncTaskService.d.ts +0 -7
- package/dist/service/asyncTask/AsyncTaskService.js +0 -34
- package/dist/service/asyncTask/handler/ExcelInfoModel.d.ts +0 -10
- package/dist/service/asyncTask/handler/ExcelInfoModel.js +0 -2
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.d.ts +0 -7
- package/dist/service/asyncTask/handler/ExportExcelAsyncTaskHandler.js +0 -216
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.d.ts +0 -36
- package/dist/service/asyncTask/handler/ExportExcelByInnerHttpHandler.js +0 -139
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.d.ts +0 -46
- package/dist/service/asyncTask/handler/ExportExcelByStdCrudHandler.js +0 -121
- package/dist/service/base/ApiBaseService.d.ts +0 -15
- package/dist/service/base/ApiBaseService.js +0 -50
- package/dist/service/base/ApiRateLimiter.d.ts +0 -10
- package/dist/service/base/ApiRateLimiter.js +0 -51
- package/dist/service/base/BaseService.d.ts +0 -41
- package/dist/service/base/BaseService.js +0 -101
- package/dist/service/base/RedisCacheService.d.ts +0 -20
- package/dist/service/base/RedisCacheService.js +0 -57
- package/dist/service/crudstd/CrudStdActionService.d.ts +0 -17
- package/dist/service/crudstd/CrudStdActionService.js +0 -32
- package/dist/service/crudstd/CrudStdConstant.d.ts +0 -58
- package/dist/service/crudstd/CrudStdConstant.js +0 -64
- package/dist/service/crudstd/CrudStdRelationService.d.ts +0 -10
- package/dist/service/crudstd/CrudStdRelationService.js +0 -85
- package/dist/service/crudstd/CrudStdService.d.ts +0 -57
- package/dist/service/crudstd/CrudStdService.js +0 -239
- package/dist/service/curd/CrudProQuick.d.ts +0 -24
- package/dist/service/curd/CrudProQuick.js +0 -109
- package/dist/service/curd/CurdMixByAccountService.d.ts +0 -9
- package/dist/service/curd/CurdMixByAccountService.js +0 -93
- package/dist/service/curd/CurdMixByDictService.d.ts +0 -13
- package/dist/service/curd/CurdMixByDictService.js +0 -114
- package/dist/service/curd/CurdMixByLinkToCustomService.d.ts +0 -31
- package/dist/service/curd/CurdMixByLinkToCustomService.js +0 -203
- package/dist/service/curd/CurdMixBySysConfigService.d.ts +0 -9
- package/dist/service/curd/CurdMixBySysConfigService.js +0 -80
- package/dist/service/curd/CurdMixByWorkbenchService.d.ts +0 -10
- package/dist/service/curd/CurdMixByWorkbenchService.js +0 -78
- package/dist/service/curd/CurdMixService.d.ts +0 -27
- package/dist/service/curd/CurdMixService.js +0 -100
- package/dist/service/curd/CurdMixUtils.d.ts +0 -51
- package/dist/service/curd/CurdMixUtils.js +0 -275
- package/dist/service/curd/CurdProService.d.ts +0 -32
- package/dist/service/curd/CurdProService.js +0 -210
- package/dist/service/curd/fixCfgModel.d.ts +0 -3
- package/dist/service/curd/fixCfgModel.js +0 -107
- package/dist/service/proxyapi/ProxyApiLoadService.d.ts +0 -21
- package/dist/service/proxyapi/ProxyApiLoadService.js +0 -167
- package/dist/service/proxyapi/ProxyApiService.d.ts +0 -60
- package/dist/service/proxyapi/ProxyApiService.js +0 -260
- package/dist/service/proxyapi/ProxyApiUtils.d.ts +0 -15
- package/dist/service/proxyapi/ProxyApiUtils.js +0 -34
- package/dist/service/proxyapi/RouteHandler.d.ts +0 -5
- package/dist/service/proxyapi/RouteHandler.js +0 -9
- package/dist/service/proxyapi/RouteTrie.d.ts +0 -12
- package/dist/service/proxyapi/RouteTrie.js +0 -63
- package/dist/service/proxyapi/WeightedRandom.d.ts +0 -9
- package/dist/service/proxyapi/WeightedRandom.js +0 -31
- package/dist/service/proxyapi/WeightedRoundRobin.d.ts +0 -8
- package/dist/service/proxyapi/WeightedRoundRobin.js +0 -32
- package/dist/views/404_app.html +0 -31
- package/dist/views/404_workbench.html +0 -34
- package/dist/views/static/favicon.ico +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
/**
|
|
4
|
-
* 只支持前缀匹配
|
|
5
|
-
* 【/ns/gw/proxy/[upstreamName]/】api/userinfo ==> http://127.0.0.1:3000/api/userinfo
|
|
6
|
-
* FaaS方式配置的接口
|
|
7
|
-
*/
|
|
8
|
-
export declare class ProxyApiGatewayController extends BaseApiController {
|
|
9
|
-
protected ctx: Context;
|
|
10
|
-
private proxyApiService;
|
|
11
|
-
private workbenchService;
|
|
12
|
-
private proxyApiLoadService;
|
|
13
|
-
/**
|
|
14
|
-
* 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
|
|
15
|
-
*/
|
|
16
|
-
executeProxyApi(): Promise<any>;
|
|
17
|
-
buildRouteTrie(workbench_code: string): Promise<import("../../service/proxyapi/RouteTrie").RouteTrie>;
|
|
18
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ProxyApiGatewayController = void 0;
|
|
16
|
-
const core_1 = require("@midwayjs/core");
|
|
17
|
-
const BaseApiController_1 = require("../base/BaseApiController");
|
|
18
|
-
const ProxyApiService_1 = require("../../service/proxyapi/ProxyApiService");
|
|
19
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
20
|
-
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
21
|
-
const ProxyApiLoadService_1 = require("../../service/proxyapi/ProxyApiLoadService");
|
|
22
|
-
/**
|
|
23
|
-
* 只支持前缀匹配
|
|
24
|
-
* 【/ns/gw/proxy/[upstreamName]/】api/userinfo ==> http://127.0.0.1:3000/api/userinfo
|
|
25
|
-
* FaaS方式配置的接口
|
|
26
|
-
*/
|
|
27
|
-
let ProxyApiGatewayController = class ProxyApiGatewayController extends BaseApiController_1.BaseApiController {
|
|
28
|
-
/**
|
|
29
|
-
* 执行配置出来的接口的接口。此接口本身不需要鉴权。鉴权信息在配置中由curdPro底层进行鉴权
|
|
30
|
-
*/
|
|
31
|
-
async executeProxyApi() {
|
|
32
|
-
const workbenchInfo = await this.workbenchService.getCurrentHostWorkbenchInfo();
|
|
33
|
-
if (!workbenchInfo) {
|
|
34
|
-
return common_dto_1.CommonResult.errorRes('域名站点不存在');
|
|
35
|
-
}
|
|
36
|
-
const workbench_code = workbenchInfo.workbench_code;
|
|
37
|
-
// const path_prefix2 = '/' + entity.upstream_code + entity.path_prefix;
|
|
38
|
-
// 路由树的结构是 /${entity.upstream_code}${entity.path_prefix}
|
|
39
|
-
const path2 = this.ctx.path.replace(/^\/ns\/gw\/proxy/, '');
|
|
40
|
-
return this.proxyApiService.handleProxyRequest(workbench_code, path2);
|
|
41
|
-
}
|
|
42
|
-
async buildRouteTrie(workbench_code) {
|
|
43
|
-
return this.proxyApiLoadService.buildRouteTrie(workbench_code);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, core_1.Inject)(),
|
|
48
|
-
__metadata("design:type", Object)
|
|
49
|
-
], ProxyApiGatewayController.prototype, "ctx", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, core_1.Inject)(),
|
|
52
|
-
__metadata("design:type", ProxyApiService_1.ProxyApiService)
|
|
53
|
-
], ProxyApiGatewayController.prototype, "proxyApiService", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, core_1.Inject)(),
|
|
56
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
57
|
-
], ProxyApiGatewayController.prototype, "workbenchService", void 0);
|
|
58
|
-
__decorate([
|
|
59
|
-
(0, core_1.Inject)(),
|
|
60
|
-
__metadata("design:type", ProxyApiLoadService_1.ProxyApiLoadService)
|
|
61
|
-
], ProxyApiGatewayController.prototype, "proxyApiLoadService", void 0);
|
|
62
|
-
__decorate([
|
|
63
|
-
(0, core_1.All)('/*'),
|
|
64
|
-
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", []),
|
|
66
|
-
__metadata("design:returntype", Promise)
|
|
67
|
-
], ProxyApiGatewayController.prototype, "executeProxyApi", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
(0, core_1.All)('/buildRouteTrie'),
|
|
70
|
-
__param(0, (0, core_1.Query)('workbench_code')),
|
|
71
|
-
__metadata("design:type", Function),
|
|
72
|
-
__metadata("design:paramtypes", [String]),
|
|
73
|
-
__metadata("design:returntype", Promise)
|
|
74
|
-
], ProxyApiGatewayController.prototype, "buildRouteTrie", null);
|
|
75
|
-
ProxyApiGatewayController = __decorate([
|
|
76
|
-
(0, core_1.Controller)('/ns/gw/proxy')
|
|
77
|
-
], ProxyApiGatewayController);
|
|
78
|
-
exports.ProxyApiGatewayController = ProxyApiGatewayController;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Context } from '@midwayjs/koa';
|
|
2
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
3
|
-
import { CommonResult } from '../../libs/utils/common-dto';
|
|
4
|
-
/**
|
|
5
|
-
* 公开的API,无需鉴权,所有人可以直接访问
|
|
6
|
-
*/
|
|
7
|
-
export declare class PublicApiController extends BaseApiController {
|
|
8
|
-
protected ctx: Context;
|
|
9
|
-
private enumInfoService;
|
|
10
|
-
private workbenchService;
|
|
11
|
-
/**
|
|
12
|
-
* 获取所有站点列表
|
|
13
|
-
*/
|
|
14
|
-
getAllWorkbenchInfoList(): Promise<CommonResult>;
|
|
15
|
-
/**
|
|
16
|
-
* 获取菜单信息
|
|
17
|
-
*/
|
|
18
|
-
getWorkbenchMenu(): Promise<CommonResult>;
|
|
19
|
-
/**
|
|
20
|
-
* 获取页面信息
|
|
21
|
-
*/
|
|
22
|
-
getNavPageInfo(): Promise<CommonResult>;
|
|
23
|
-
/**
|
|
24
|
-
* 获取配置的枚举项信息: 都是无需鉴权的
|
|
25
|
-
*/
|
|
26
|
-
getEnumInfo(): Promise<CommonResult>;
|
|
27
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PublicApiController = void 0;
|
|
13
|
-
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const _ = require("lodash");
|
|
15
|
-
const BaseApiController_1 = require("../base/BaseApiController");
|
|
16
|
-
const SystemTables_1 = require("../../models/SystemTables");
|
|
17
|
-
const EnumInfoService_1 = require("../../service/EnumInfoService");
|
|
18
|
-
const common_dto_1 = require("../../libs/utils/common-dto");
|
|
19
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
20
|
-
const WorkbenchService_1 = require("../../service/WorkbenchService");
|
|
21
|
-
const SystemPerm_1 = require("../../models/SystemPerm");
|
|
22
|
-
const keys_1 = require("../../libs/crud-pro/models/keys");
|
|
23
|
-
/**
|
|
24
|
-
* 公开的API,无需鉴权,所有人可以直接访问
|
|
25
|
-
*/
|
|
26
|
-
let PublicApiController = class PublicApiController extends BaseApiController_1.BaseApiController {
|
|
27
|
-
/**
|
|
28
|
-
* 获取所有站点列表
|
|
29
|
-
*/
|
|
30
|
-
async getAllWorkbenchInfoList() {
|
|
31
|
-
const entities = await this.workbenchService.getAllWorkbenchInfoList(false);
|
|
32
|
-
const entities2 = entities.map(e => {
|
|
33
|
-
return {
|
|
34
|
-
workbench_domain: e.workbench_domain,
|
|
35
|
-
workbench_code: e.workbench_code,
|
|
36
|
-
workbench_desc: e.workbench_desc,
|
|
37
|
-
workbench_name: e.workbench_name,
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
return common_dto_1.CommonResult.successRes(entities2);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 获取菜单信息
|
|
44
|
-
*/
|
|
45
|
-
async getWorkbenchMenu() {
|
|
46
|
-
const query = this.ctx.query || {};
|
|
47
|
-
const workbenchMenuCode = query.workbenchMenuCode;
|
|
48
|
-
if (!workbenchMenuCode) {
|
|
49
|
-
return common_dto_1.CommonResult.errorRes('param workbenchMenuCode is null');
|
|
50
|
-
}
|
|
51
|
-
const workbenchMenuCodeStr = '' + workbenchMenuCode;
|
|
52
|
-
const workbenchMenuCodeArray = workbenchMenuCodeStr.split(',');
|
|
53
|
-
const condition = {
|
|
54
|
-
menu_code: {
|
|
55
|
-
$in: workbenchMenuCodeArray,
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
const rows = await this.sysDBUtil.getList({ condition }, SystemTables_1.SystemTables.sys_menus);
|
|
59
|
-
if (!rows || rows.length === 0) {
|
|
60
|
-
return common_dto_1.CommonResult.errorRes('sys_config is null', '', { condition });
|
|
61
|
-
}
|
|
62
|
-
const map = {};
|
|
63
|
-
for (let i = 0; i < rows.length; i++) {
|
|
64
|
-
const rowElement = rows[i];
|
|
65
|
-
const menu_code = rowElement.menu_code;
|
|
66
|
-
const view_auth_config = rowElement.view_auth_config;
|
|
67
|
-
const view_auth_type = rowElement.view_auth_type;
|
|
68
|
-
const hasPermission = this.ctx.userSession.isAuthPass(view_auth_type, view_auth_config);
|
|
69
|
-
const menu_config_content = rowElement.menu_config_content;
|
|
70
|
-
delete rowElement.menu_config_content;
|
|
71
|
-
const menu_list = (0, functions_1.parseJsonObject)(menu_config_content) || [];
|
|
72
|
-
map[menu_code] = { ...rowElement, menu_list, hasPermission };
|
|
73
|
-
}
|
|
74
|
-
// 特殊的devops菜单
|
|
75
|
-
map['devops'] = {
|
|
76
|
-
menu_list: [],
|
|
77
|
-
hasPermission: this.ctx.userSession.isAuthPass(keys_1.KeysOfAuthType.byRoleCode, [SystemPerm_1.SystemRoleCode.DevOpsWriter, SystemPerm_1.SystemRoleCode.DevOpsViewer, SystemPerm_1.SystemRoleCode.SuperAdmin]),
|
|
78
|
-
};
|
|
79
|
-
return common_dto_1.CommonResult.successRes(map);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 获取页面信息
|
|
83
|
-
*/
|
|
84
|
-
async getNavPageInfo() {
|
|
85
|
-
const body = this.ctx.request.body;
|
|
86
|
-
const { workbenchCode, appCode, pathname } = body;
|
|
87
|
-
const resultData = {};
|
|
88
|
-
const getOne = async (condition, tablenName, key) => {
|
|
89
|
-
const values = Object.values(condition).filter(Boolean);
|
|
90
|
-
// 查询条件不能为空
|
|
91
|
-
if (values.length > 0) {
|
|
92
|
-
const oneData = await this.sysDBUtil.getOne({ condition }, tablenName);
|
|
93
|
-
if (oneData && oneData['app_schema']) {
|
|
94
|
-
oneData['app_schema'] = (0, functions_1.parseJsonObject)(oneData['app_schema']);
|
|
95
|
-
}
|
|
96
|
-
resultData[key] = oneData;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
await getOne({ app_code: appCode }, SystemTables_1.SystemTables.sys_app, 'appData');
|
|
100
|
-
await getOne({ page_path: pathname, workbench_code: workbenchCode }, SystemTables_1.SystemTables.sys_app_page, 'pageData');
|
|
101
|
-
return common_dto_1.CommonResult.successRes(resultData);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 获取配置的枚举项信息: 都是无需鉴权的
|
|
105
|
-
*/
|
|
106
|
-
async getEnumInfo() {
|
|
107
|
-
const body = this.ctx.request.body;
|
|
108
|
-
const query = this.ctx.query || {};
|
|
109
|
-
let codeList = _.get(body, 'codeList');
|
|
110
|
-
const refreshCache = `${_.get(body, 'refreshCache')}` === 'true' || query.refreshCache === 'true';
|
|
111
|
-
if (query.codeList) {
|
|
112
|
-
//codeList=dict@@SexEnum,sysCfgEnum@@EntityStatusEnum
|
|
113
|
-
const codeListStr = query.codeList;
|
|
114
|
-
codeList = codeListStr.split(',').map(str => {
|
|
115
|
-
const ss = str.split('@@');
|
|
116
|
-
return {
|
|
117
|
-
type: ss[0],
|
|
118
|
-
code: ss[1],
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
const enumInfos = await this.enumInfoService.queryEnumInfo(codeList, refreshCache);
|
|
123
|
-
return common_dto_1.CommonResult.successRes(enumInfos);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
__decorate([
|
|
127
|
-
(0, core_1.Inject)(),
|
|
128
|
-
__metadata("design:type", Object)
|
|
129
|
-
], PublicApiController.prototype, "ctx", void 0);
|
|
130
|
-
__decorate([
|
|
131
|
-
(0, core_1.Inject)(),
|
|
132
|
-
__metadata("design:type", EnumInfoService_1.EnumInfoService)
|
|
133
|
-
], PublicApiController.prototype, "enumInfoService", void 0);
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, core_1.Inject)(),
|
|
136
|
-
__metadata("design:type", WorkbenchService_1.WorkbenchService)
|
|
137
|
-
], PublicApiController.prototype, "workbenchService", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
(0, core_1.Get)('/getAllWorkbenchInfoList'),
|
|
140
|
-
__metadata("design:type", Function),
|
|
141
|
-
__metadata("design:paramtypes", []),
|
|
142
|
-
__metadata("design:returntype", Promise)
|
|
143
|
-
], PublicApiController.prototype, "getAllWorkbenchInfoList", null);
|
|
144
|
-
__decorate([
|
|
145
|
-
(0, core_1.Get)('/getWorkbenchMenu'),
|
|
146
|
-
__metadata("design:type", Function),
|
|
147
|
-
__metadata("design:paramtypes", []),
|
|
148
|
-
__metadata("design:returntype", Promise)
|
|
149
|
-
], PublicApiController.prototype, "getWorkbenchMenu", null);
|
|
150
|
-
__decorate([
|
|
151
|
-
(0, core_1.Post)('/getNavPageInfo'),
|
|
152
|
-
__metadata("design:type", Function),
|
|
153
|
-
__metadata("design:paramtypes", []),
|
|
154
|
-
__metadata("design:returntype", Promise)
|
|
155
|
-
], PublicApiController.prototype, "getNavPageInfo", null);
|
|
156
|
-
__decorate([
|
|
157
|
-
(0, core_1.Post)('/getEnumInfo'),
|
|
158
|
-
__metadata("design:type", Function),
|
|
159
|
-
__metadata("design:paramtypes", []),
|
|
160
|
-
__metadata("design:returntype", Promise)
|
|
161
|
-
], PublicApiController.prototype, "getEnumInfo", null);
|
|
162
|
-
PublicApiController = __decorate([
|
|
163
|
-
(0, core_1.Controller)('/ns/gw/api/publicApi')
|
|
164
|
-
], PublicApiController);
|
|
165
|
-
exports.PublicApiController = PublicApiController;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { BaseApiController } from '../base/BaseApiController';
|
|
4
|
-
interface HttpGetRes {
|
|
5
|
-
statusCode: number;
|
|
6
|
-
headers: any;
|
|
7
|
-
body: NodeJS.ReadableStream;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 静态文件代理功能
|
|
11
|
-
*/
|
|
12
|
-
export declare class StaticController extends BaseApiController {
|
|
13
|
-
protected ctx: Context;
|
|
14
|
-
constructor();
|
|
15
|
-
private getLocalPaths;
|
|
16
|
-
private initNotFoundList;
|
|
17
|
-
private responseLocalFile;
|
|
18
|
-
proxyStaticFile(ossName: string, relativePath: string): Promise<string>;
|
|
19
|
-
saveNotFoundList(): Promise<void>;
|
|
20
|
-
httpsGet(url: string): Promise<HttpGetRes>;
|
|
21
|
-
writeResponseToFile(httpsGetRes: HttpGetRes, localFilePath: string, localHeaderPath: string): Promise<void>;
|
|
22
|
-
getMimeType(filePath: string): any;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.StaticController = void 0;
|
|
16
|
-
const core_1 = require("@midwayjs/core");
|
|
17
|
-
const BaseApiController_1 = require("../base/BaseApiController");
|
|
18
|
-
const fs = require("fs/promises");
|
|
19
|
-
const fs2 = require("fs");
|
|
20
|
-
const path = require("path");
|
|
21
|
-
const https = require("https");
|
|
22
|
-
const functions_1 = require("../../libs/utils/functions");
|
|
23
|
-
function getPathConfig(ossName) {
|
|
24
|
-
const remoteBaseUrlMap = {
|
|
25
|
-
cdnjsx: 'https://cdnjsx.oss-cn-shanghai.aliyuncs.com',
|
|
26
|
-
'i.alicdn.com': 'https://i.alicdn.com',
|
|
27
|
-
'img.alicdn.com': 'https://img.alicdn.com',
|
|
28
|
-
'at.alicdn.com': 'https://at.alicdn.com',
|
|
29
|
-
};
|
|
30
|
-
let remoteBaseUrl = remoteBaseUrlMap[ossName];
|
|
31
|
-
if (!remoteBaseUrl) {
|
|
32
|
-
console.error(`getPathConfig ossName: ${ossName} 未配置`);
|
|
33
|
-
remoteBaseUrl = `https://${ossName}`;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
remoteBaseUrl,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// 404列表缓存
|
|
40
|
-
let notFoundList = new Set();
|
|
41
|
-
let notFoundListIsInit = false;
|
|
42
|
-
/**
|
|
43
|
-
* 静态文件代理功能
|
|
44
|
-
*/
|
|
45
|
-
let StaticController = class StaticController extends BaseApiController_1.BaseApiController {
|
|
46
|
-
constructor() {
|
|
47
|
-
super();
|
|
48
|
-
this.initNotFoundList();
|
|
49
|
-
}
|
|
50
|
-
getLocalPaths() {
|
|
51
|
-
const appDir = this.app.getAppDir();
|
|
52
|
-
const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
|
|
53
|
-
const notFoundListFile = path.join(localDir, '__404__list.json'); // 404列表文件
|
|
54
|
-
return {
|
|
55
|
-
localDir,
|
|
56
|
-
notFoundListFile,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
async initNotFoundList() {
|
|
60
|
-
if (notFoundListIsInit) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
notFoundListIsInit = true;
|
|
64
|
-
const { localDir, notFoundListFile } = this.getLocalPaths();
|
|
65
|
-
try {
|
|
66
|
-
// 确保本地存储目录存在
|
|
67
|
-
await fs.mkdir(localDir, { recursive: true });
|
|
68
|
-
const data = await fs.readFile(notFoundListFile, 'utf8');
|
|
69
|
-
notFoundList = new Set(JSON.parse(data));
|
|
70
|
-
console.log(`已加载${notFoundList.size}个404记录`);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
if (error.code !== 'ENOENT') {
|
|
74
|
-
console.error('读取404列表失败:', error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async responseLocalFile(localFilePath, localHeaderPath, relativePath) {
|
|
79
|
-
const headers = {
|
|
80
|
-
'Cache-Control': 'public, max-age=31536000',
|
|
81
|
-
Expires: new Date(Date.now() + 31536000000).toUTCString(),
|
|
82
|
-
};
|
|
83
|
-
try {
|
|
84
|
-
// 检查本地文件是否存在.头文件
|
|
85
|
-
const stats = await fs.stat(localHeaderPath);
|
|
86
|
-
if (stats.isFile()) {
|
|
87
|
-
const headerDataStr = await fs.readFile(localHeaderPath, 'utf8');
|
|
88
|
-
const headerData = (0, functions_1.parseJsonObject)(headerDataStr);
|
|
89
|
-
if (headerData) {
|
|
90
|
-
headers['content-type'] = headerData['content-type'];
|
|
91
|
-
headers['content-length'] = headerData['content-length'];
|
|
92
|
-
headers['last-modified'] = headerData['last-modified'];
|
|
93
|
-
headers['etag'] = headerData['etag'];
|
|
94
|
-
headers['cache-control'] = headerData['cache-control'];
|
|
95
|
-
headers['accept-ranges'] = headerData['accept-ranges'];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
this.logDebug('[StaticController]responseLocalFile', error);
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
// 检查本地文件是否存在
|
|
104
|
-
const stats = await fs.stat(localFilePath);
|
|
105
|
-
if (stats.isFile()) {
|
|
106
|
-
if (!headers['content-type']) {
|
|
107
|
-
headers['content-type'] = this.getMimeType(localFilePath);
|
|
108
|
-
}
|
|
109
|
-
const stream = fs2.createReadStream(localFilePath);
|
|
110
|
-
stream.setMaxListeners(50);
|
|
111
|
-
// const oldOn = stream.on.bind(stream);
|
|
112
|
-
// stream.on = (...args)=>{
|
|
113
|
-
// return oldOn(...args)
|
|
114
|
-
// }
|
|
115
|
-
this.logInfo(`[StaticController]返回本地文件: ${relativePath}`);
|
|
116
|
-
this.ctx.status = 200;
|
|
117
|
-
this.ctx.set(headers);
|
|
118
|
-
this.ctx.body = stream;
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
// 文件不存在,继续请求远程
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
async proxyStaticFile(ossName, relativePath) {
|
|
128
|
-
const { localDir } = this.getLocalPaths();
|
|
129
|
-
const PATH_CONFIG = getPathConfig(ossName);
|
|
130
|
-
// 构建本地路径和远程路径
|
|
131
|
-
const localFilePath = path.join(localDir, 'files', ossName, relativePath);
|
|
132
|
-
const localHeaderPath = path.join(localDir, 'headers', ossName, relativePath);
|
|
133
|
-
const remoteUrl = `${PATH_CONFIG.remoteBaseUrl}/${relativePath}`;
|
|
134
|
-
// 检查是否在404列表中
|
|
135
|
-
if (notFoundList.has(relativePath)) {
|
|
136
|
-
this.ctx.status = 404;
|
|
137
|
-
return this.ctx.render('500', { errorMsg: ' 远程文件不存在, 命中notFoundList' });
|
|
138
|
-
}
|
|
139
|
-
// 检查并返回本地文件
|
|
140
|
-
if (await this.responseLocalFile(localFilePath, localHeaderPath, relativePath)) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
// 请求远程文件
|
|
144
|
-
this.logInfo(`[StaticController]请求远程文件: ${remoteUrl}`);
|
|
145
|
-
try {
|
|
146
|
-
const remoteRes = await this.httpsGet(remoteUrl);
|
|
147
|
-
// 处理远程响应状态码
|
|
148
|
-
if (remoteRes.statusCode === 200) {
|
|
149
|
-
// 写入本地文件
|
|
150
|
-
await this.writeResponseToFile(remoteRes, localFilePath, localHeaderPath);
|
|
151
|
-
// 检查并返回本地文件
|
|
152
|
-
if (await this.responseLocalFile(localFilePath, localHeaderPath, relativePath)) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else if (remoteRes.statusCode === 404) {
|
|
157
|
-
// 记录404并返回
|
|
158
|
-
notFoundList.add(relativePath);
|
|
159
|
-
await this.saveNotFoundList();
|
|
160
|
-
this.logInfo(`[StaticController]远程文件不存在,已记录404: ${relativePath}`);
|
|
161
|
-
this.ctx.status = 404;
|
|
162
|
-
return this.ctx.render('500', { errorMsg: ' 远程文件不存在,已记录404' });
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
// 其他状态码
|
|
166
|
-
const msg = `[StaticController]远程服务器返回状态码: ${remoteRes.statusCode}`;
|
|
167
|
-
this.logInfo(msg);
|
|
168
|
-
this.ctx.status = 502;
|
|
169
|
-
return this.ctx.render('500', { errorMsg: msg });
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
catch (err) {
|
|
173
|
-
const msg = `[StaticController]请求远程文件失败: ${err}`;
|
|
174
|
-
this.logError(msg);
|
|
175
|
-
this.ctx.status = 500;
|
|
176
|
-
return this.ctx.render('500', { errorMsg: msg });
|
|
177
|
-
}
|
|
178
|
-
this.ctx.status = 500;
|
|
179
|
-
return this.ctx.render('500', { errorMsg: '未知异常' });
|
|
180
|
-
}
|
|
181
|
-
// 保存404列表
|
|
182
|
-
async saveNotFoundList() {
|
|
183
|
-
const { notFoundListFile } = this.getLocalPaths();
|
|
184
|
-
try {
|
|
185
|
-
// 确保存储404列表的目录存在
|
|
186
|
-
const dir = path.dirname(notFoundListFile);
|
|
187
|
-
await fs.mkdir(dir, { recursive: true });
|
|
188
|
-
await fs.writeFile(notFoundListFile, JSON.stringify(Array.from(notFoundList), null), 'utf8');
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
this.logError('[StaticController]保存404列表失败:', error);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// 封装https请求为异步函数
|
|
195
|
-
async httpsGet(url) {
|
|
196
|
-
return new Promise((resolve, reject) => {
|
|
197
|
-
https
|
|
198
|
-
.get(url, res => {
|
|
199
|
-
resolve({
|
|
200
|
-
statusCode: res.statusCode || 500,
|
|
201
|
-
headers: res.headers,
|
|
202
|
-
body: res,
|
|
203
|
-
});
|
|
204
|
-
})
|
|
205
|
-
.on('error', err => {
|
|
206
|
-
reject(err);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
// 新增:将响应body写入文件的函数
|
|
211
|
-
async writeResponseToFile(httpsGetRes, localFilePath, localHeaderPath) {
|
|
212
|
-
// 创建本地目录(如果不存在)
|
|
213
|
-
const localFileDir = path.dirname(localFilePath);
|
|
214
|
-
await fs.mkdir(localFileDir, { recursive: true });
|
|
215
|
-
const localHeaderDir = path.dirname(localHeaderPath);
|
|
216
|
-
await fs.mkdir(localHeaderDir, { recursive: true });
|
|
217
|
-
try {
|
|
218
|
-
const { statusCode, body } = httpsGetRes;
|
|
219
|
-
// 检查HTTP状态码
|
|
220
|
-
if (statusCode >= 400) {
|
|
221
|
-
throw new Error(`HTTP请求失败,状态码: ${statusCode}`);
|
|
222
|
-
}
|
|
223
|
-
// 创建可写流
|
|
224
|
-
const fileStream = fs2.createWriteStream(localFilePath);
|
|
225
|
-
// 使用管道将响应流写入文件
|
|
226
|
-
await new Promise((resolve, reject) => {
|
|
227
|
-
body.pipe(fileStream);
|
|
228
|
-
body.on('error', err => {
|
|
229
|
-
reject(new Error(`读取响应流失败: ${err.message}`));
|
|
230
|
-
});
|
|
231
|
-
fileStream.on('finish', resolve);
|
|
232
|
-
fileStream.on('error', err => {
|
|
233
|
-
reject(new Error(`写入文件失败: ${err.message}`));
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
this.logInfo(`[StaticController]文件已成功写入1: ${localFilePath}`);
|
|
237
|
-
await fs.writeFile(localHeaderPath, JSON.stringify(httpsGetRes.headers), 'utf8');
|
|
238
|
-
this.logInfo(`[StaticController]文件已成功写入2: ${localHeaderPath}`);
|
|
239
|
-
}
|
|
240
|
-
catch (err) {
|
|
241
|
-
// 发生错误时删除可能存在的不完整文件
|
|
242
|
-
if (fs2.existsSync(localFilePath)) {
|
|
243
|
-
fs2.unlinkSync(localFilePath);
|
|
244
|
-
}
|
|
245
|
-
throw new Error(`下载过程中发生错误: ${err.message}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
// 根据文件扩展名获取MIME类型
|
|
249
|
-
getMimeType(filePath) {
|
|
250
|
-
const extname = path.extname(filePath).toLowerCase();
|
|
251
|
-
const mimeTypes = {
|
|
252
|
-
'.html': 'text/html',
|
|
253
|
-
'.js': 'text/javascript',
|
|
254
|
-
'.css': 'text/css',
|
|
255
|
-
'.json': 'application/json',
|
|
256
|
-
'.png': 'image/png',
|
|
257
|
-
'.jpg': 'image/jpg',
|
|
258
|
-
'.gif': 'image/gif',
|
|
259
|
-
'.svg': 'image/svg+xml',
|
|
260
|
-
'.woff': 'font/woff',
|
|
261
|
-
'.woff2': 'font/woff2',
|
|
262
|
-
'.ttf': 'font/ttf',
|
|
263
|
-
'.eot': 'application/vnd.ms-fontobject',
|
|
264
|
-
'.txt': 'text/plain',
|
|
265
|
-
'.pdf': 'application/pdf',
|
|
266
|
-
'.mp4': 'video/mp4',
|
|
267
|
-
'.ico': 'image/x-icon',
|
|
268
|
-
};
|
|
269
|
-
return mimeTypes[extname] || 'application/octet-stream';
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
__decorate([
|
|
273
|
-
(0, core_1.Inject)(),
|
|
274
|
-
__metadata("design:type", Object)
|
|
275
|
-
], StaticController.prototype, "ctx", void 0);
|
|
276
|
-
__decorate([
|
|
277
|
-
(0, core_1.All)('/:ossName/:relativePath+'),
|
|
278
|
-
__param(0, (0, core_1.Param)('ossName')),
|
|
279
|
-
__param(1, (0, core_1.Param)('relativePath')),
|
|
280
|
-
__metadata("design:type", Function),
|
|
281
|
-
__metadata("design:paramtypes", [String, String]),
|
|
282
|
-
__metadata("design:returntype", Promise)
|
|
283
|
-
], StaticController.prototype, "proxyStaticFile", null);
|
|
284
|
-
StaticController = __decorate([
|
|
285
|
-
(0, core_1.Controller)('/ns/static'),
|
|
286
|
-
__metadata("design:paramtypes", [])
|
|
287
|
-
], StaticController);
|
|
288
|
-
exports.StaticController = StaticController;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Context } from '@midwayjs/koa';
|
|
3
|
-
import { CurdMixService } from '../service/curd/CurdMixService';
|
|
4
|
-
import { CommonResult } from '../libs/utils/common-dto';
|
|
5
|
-
export declare class HelpersApi {
|
|
6
|
-
protected ctx: Context;
|
|
7
|
-
private midwayWebRouterService;
|
|
8
|
-
protected curdMixService: CurdMixService;
|
|
9
|
-
getApiEnv(): Promise<{
|
|
10
|
-
env: string;
|
|
11
|
-
href: string;
|
|
12
|
-
host: string;
|
|
13
|
-
ctx: Context;
|
|
14
|
-
processInfo: {
|
|
15
|
-
version: string;
|
|
16
|
-
versions: NodeJS.ProcessVersions;
|
|
17
|
-
env: NodeJS.ProcessEnv;
|
|
18
|
-
argv: string[];
|
|
19
|
-
cwd: string;
|
|
20
|
-
};
|
|
21
|
-
}>;
|
|
22
|
-
getApiScript(queryData: any): Promise<string>;
|
|
23
|
-
testExecuteCrudByCfg(): Promise<import("../libs/crud-pro/models/ExecuteContext").ExecuteContext>;
|
|
24
|
-
/**
|
|
25
|
-
* 工具函数: 由明文生成数据库中的存储的密码
|
|
26
|
-
* @param queryData
|
|
27
|
-
*/
|
|
28
|
-
generateDatabasePassword(queryData: any): Promise<{
|
|
29
|
-
pwd_salt: string;
|
|
30
|
-
pwd_md5: string;
|
|
31
|
-
login_name: any;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* 工具函数: 使用Aes128CBC加密
|
|
35
|
-
* @param queryData
|
|
36
|
-
*/
|
|
37
|
-
cryptoAes128CBC(queryData: any): Promise<CommonResult>;
|
|
38
|
-
private checkLocalPermissionEnv;
|
|
39
|
-
}
|