@hlw-midway/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/bin/check.d.ts +4 -0
- package/dist/bin/check.js +41 -0
- package/dist/bin/entity.d.ts +8 -0
- package/dist/bin/entity.js +50 -0
- package/dist/bin/index.d.ts +2 -0
- package/dist/bin/index.js +49 -0
- package/dist/bin/obfuscate.d.ts +1 -0
- package/dist/bin/obfuscate.js +69 -0
- package/dist/cache/store.d.ts +18 -0
- package/dist/cache/store.js +38 -0
- package/dist/config/config.default.d.ts +8 -0
- package/dist/config/config.default.js +22 -0
- package/dist/configuration.d.ts +17 -0
- package/dist/configuration.js +106 -0
- package/dist/constant/global.d.ts +59 -0
- package/dist/constant/global.js +85 -0
- package/dist/controller/base.d.ts +107 -0
- package/dist/controller/base.js +236 -0
- package/dist/decorator/cache.d.ts +2 -0
- package/dist/decorator/cache.js +10 -0
- package/dist/decorator/controller.d.ts +71 -0
- package/dist/decorator/controller.js +169 -0
- package/dist/decorator/event.d.ts +21 -0
- package/dist/decorator/event.js +39 -0
- package/dist/decorator/index.d.ts +22 -0
- package/dist/decorator/index.js +120 -0
- package/dist/decorator/tag.d.ts +22 -0
- package/dist/decorator/tag.js +40 -0
- package/dist/decorator/transaction.d.ts +8 -0
- package/dist/decorator/transaction.js +10 -0
- package/dist/entity/base.d.ts +10 -0
- package/dist/entity/base.js +41 -0
- package/dist/entity/mongo.d.ts +10 -0
- package/dist/entity/mongo.js +35 -0
- package/dist/entity/typeorm.d.ts +3 -0
- package/dist/entity/typeorm.js +7 -0
- package/dist/event/index.d.ts +53 -0
- package/dist/event/index.js +188 -0
- package/dist/exception/base.d.ts +8 -0
- package/dist/exception/base.js +15 -0
- package/dist/exception/comm.d.ts +7 -0
- package/dist/exception/comm.js +15 -0
- package/dist/exception/core.d.ts +7 -0
- package/dist/exception/core.js +15 -0
- package/dist/exception/filter.d.ts +11 -0
- package/dist/exception/filter.js +42 -0
- package/dist/exception/validate.d.ts +7 -0
- package/dist/exception/validate.js +15 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +60 -0
- package/dist/interface.d.ts +432 -0
- package/dist/interface.js +24 -0
- package/dist/module/config.d.ts +21 -0
- package/dist/module/config.js +109 -0
- package/dist/module/import.d.ts +64 -0
- package/dist/module/import.js +244 -0
- package/dist/module/menu.d.ts +54 -0
- package/dist/module/menu.js +178 -0
- package/dist/rest/eps.d.ts +51 -0
- package/dist/rest/eps.js +269 -0
- package/dist/service/base.d.ts +167 -0
- package/dist/service/base.js +281 -0
- package/dist/service/mysql.d.ts +143 -0
- package/dist/service/mysql.js +524 -0
- package/dist/service/postgres.d.ts +160 -0
- package/dist/service/postgres.js +639 -0
- package/dist/service/sqlite.d.ts +142 -0
- package/dist/service/sqlite.js +560 -0
- package/dist/tag/data.d.ts +25 -0
- package/dist/tag/data.js +85 -0
- package/dist/util/func.d.ts +8 -0
- package/dist/util/func.js +44 -0
- package/dist/util/location.d.ts +26 -0
- package/dist/util/location.js +113 -0
- package/index.d.ts +10 -0
- package/package.json +68 -0
|
@@ -0,0 +1,42 @@
|
|
|
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.HlwExceptionFilter = void 0;
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
|
+
const global_1 = require("../constant/global");
|
|
15
|
+
const comm_1 = require("../exception/comm");
|
|
16
|
+
/**
|
|
17
|
+
* 全局异常处理
|
|
18
|
+
*/
|
|
19
|
+
let HlwExceptionFilter = class HlwExceptionFilter {
|
|
20
|
+
async catch(err) {
|
|
21
|
+
const { RESCODE } = global_1.GlobalConfig.getInstance();
|
|
22
|
+
if (err instanceof comm_1.HlwCommException) {
|
|
23
|
+
// 401/403 只输出简短信息,不输出堆栈
|
|
24
|
+
this.coreLogger.warn(`[${err.statusCode || err.status}] ${err.message}`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.coreLogger.error(err);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
code: err.status || RESCODE.COMMFAIL,
|
|
31
|
+
message: err.message,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.HlwExceptionFilter = HlwExceptionFilter;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, core_1.Logger)(),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], HlwExceptionFilter.prototype, "coreLogger", void 0);
|
|
40
|
+
exports.HlwExceptionFilter = HlwExceptionFilter = __decorate([
|
|
41
|
+
(0, core_1.Catch)()
|
|
42
|
+
], HlwExceptionFilter);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HlwValidateException = void 0;
|
|
4
|
+
const global_1 = require("../constant/global");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
/**
|
|
7
|
+
* 校验异常
|
|
8
|
+
*/
|
|
9
|
+
class HlwValidateException extends base_1.BaseException {
|
|
10
|
+
constructor(message, statusCode) {
|
|
11
|
+
const { RESCODE, RESMESSAGE } = global_1.GlobalConfig.getInstance();
|
|
12
|
+
super('HlwValidateException', RESCODE.VALIDATEFAIL, message ? message : RESMESSAGE.VALIDATEFAIL, statusCode);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HlwValidateException = HlwValidateException;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { HlwConfiguration as Configuration } from './configuration';
|
|
2
|
+
export * from './exception/filter';
|
|
3
|
+
export * from './exception/core';
|
|
4
|
+
export * from './exception/base';
|
|
5
|
+
export * from './exception/comm';
|
|
6
|
+
export * from './exception/validate';
|
|
7
|
+
export * from './cache/store';
|
|
8
|
+
export * from './entity/base';
|
|
9
|
+
export * from './entity/typeorm';
|
|
10
|
+
export * from './entity/mongo';
|
|
11
|
+
export * from './service/base';
|
|
12
|
+
export * from './service/mysql';
|
|
13
|
+
export * from './service/postgres';
|
|
14
|
+
export * from './service/sqlite';
|
|
15
|
+
export * from './controller/base';
|
|
16
|
+
export * from './event/index';
|
|
17
|
+
export * from './decorator/controller';
|
|
18
|
+
export * from './decorator/cache';
|
|
19
|
+
export * from './decorator/event';
|
|
20
|
+
export * from './decorator/transaction';
|
|
21
|
+
export * from './decorator/tag';
|
|
22
|
+
export * from './decorator/index';
|
|
23
|
+
export * from './rest/eps';
|
|
24
|
+
export * from './tag/data';
|
|
25
|
+
export * from './module/config';
|
|
26
|
+
export * from './module/import';
|
|
27
|
+
export * from './module/menu';
|
|
28
|
+
export * from './interface';
|
|
29
|
+
export * from './util/func';
|
|
30
|
+
export * from './constant/global';
|
|
31
|
+
export * from './util/location';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Configuration = void 0;
|
|
18
|
+
var configuration_1 = require("./configuration");
|
|
19
|
+
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.HlwConfiguration; } });
|
|
20
|
+
// 异常处理
|
|
21
|
+
__exportStar(require("./exception/filter"), exports);
|
|
22
|
+
__exportStar(require("./exception/core"), exports);
|
|
23
|
+
__exportStar(require("./exception/base"), exports);
|
|
24
|
+
__exportStar(require("./exception/comm"), exports);
|
|
25
|
+
__exportStar(require("./exception/validate"), exports);
|
|
26
|
+
// cache
|
|
27
|
+
__exportStar(require("./cache/store"), exports);
|
|
28
|
+
// entity
|
|
29
|
+
__exportStar(require("./entity/base"), exports);
|
|
30
|
+
__exportStar(require("./entity/typeorm"), exports);
|
|
31
|
+
__exportStar(require("./entity/mongo"), exports);
|
|
32
|
+
// service
|
|
33
|
+
__exportStar(require("./service/base"), exports);
|
|
34
|
+
__exportStar(require("./service/mysql"), exports);
|
|
35
|
+
__exportStar(require("./service/postgres"), exports);
|
|
36
|
+
__exportStar(require("./service/sqlite"), exports);
|
|
37
|
+
// controller
|
|
38
|
+
__exportStar(require("./controller/base"), exports);
|
|
39
|
+
// 事件
|
|
40
|
+
__exportStar(require("./event/index"), exports);
|
|
41
|
+
// 装饰器
|
|
42
|
+
__exportStar(require("./decorator/controller"), exports);
|
|
43
|
+
__exportStar(require("./decorator/cache"), exports);
|
|
44
|
+
__exportStar(require("./decorator/event"), exports);
|
|
45
|
+
__exportStar(require("./decorator/transaction"), exports);
|
|
46
|
+
__exportStar(require("./decorator/tag"), exports);
|
|
47
|
+
__exportStar(require("./decorator/index"), exports);
|
|
48
|
+
// rest
|
|
49
|
+
__exportStar(require("./rest/eps"), exports);
|
|
50
|
+
// tag
|
|
51
|
+
__exportStar(require("./tag/data"), exports);
|
|
52
|
+
// 模块
|
|
53
|
+
__exportStar(require("./module/config"), exports);
|
|
54
|
+
__exportStar(require("./module/import"), exports);
|
|
55
|
+
__exportStar(require("./module/menu"), exports);
|
|
56
|
+
// 其他
|
|
57
|
+
__exportStar(require("./interface"), exports);
|
|
58
|
+
__exportStar(require("./util/func"), exports);
|
|
59
|
+
__exportStar(require("./constant/global"), exports);
|
|
60
|
+
__exportStar(require("./util/location"), exports);
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { MiddlewareParamArray } from '@midwayjs/core';
|
|
2
|
+
import { AedesOptions } from 'aedes';
|
|
3
|
+
import { PublishPacket } from 'packet';
|
|
4
|
+
/**
|
|
5
|
+
* 模块配置
|
|
6
|
+
*/
|
|
7
|
+
export interface ModuleConfig {
|
|
8
|
+
/** 名称 */
|
|
9
|
+
name: string;
|
|
10
|
+
/** 描述 */
|
|
11
|
+
description: string;
|
|
12
|
+
/** 模块中间件 */
|
|
13
|
+
middlewares?: MiddlewareParamArray;
|
|
14
|
+
/** 全局中间件 */
|
|
15
|
+
globalMiddlewares?: MiddlewareParamArray;
|
|
16
|
+
/** 模块加载顺序,默认为0,值越大越优先加载 */
|
|
17
|
+
order?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface HlwConfig {
|
|
20
|
+
/** 短信 */
|
|
21
|
+
sms?: HlwSmsConfig;
|
|
22
|
+
/** 是否自动导入数据库 */
|
|
23
|
+
initDB?: boolean;
|
|
24
|
+
/** Eps */
|
|
25
|
+
eps?: boolean;
|
|
26
|
+
/** 开启多租户 */
|
|
27
|
+
tenant?: {
|
|
28
|
+
/** 是否开启 */
|
|
29
|
+
enable: boolean;
|
|
30
|
+
urls: string[];
|
|
31
|
+
};
|
|
32
|
+
/** 开启多语言 */
|
|
33
|
+
i18n?: {
|
|
34
|
+
/** 是否开启 */
|
|
35
|
+
enable: boolean;
|
|
36
|
+
/** 语言 */
|
|
37
|
+
languages: Array<'zh-cn' | 'en' | 'az' | 'de' | 'pt' | 'es' | 'da' | 'fr' | 'nb-NO' | 'zh-tw' | 'it' | 'ko' | 'ja' | 'nl' | 'vi' | 'ru' | 'tr' | 'pt-br' | 'fa' | 'th' | 'id' | 'bg' | 'pa' | 'pl' | 'fi' | 'sv' | 'el' | 'sk' | 'ca' | 'cs' | 'uk' | 'tk' | 'ta' | 'lv' | 'af' | 'et' | 'sl' | 'ar' | 'he' | 'lt' | 'mn' | 'kk' | 'hu' | 'ro' | 'ku' | 'ckb' | 'ug-cn' | 'km' | 'sr' | 'eu' | 'ky' | 'hy-am' | 'hr' | 'eo' | 'bn' | 'ms'>;
|
|
38
|
+
/** 翻译服务 */
|
|
39
|
+
serviceUrl?: string;
|
|
40
|
+
};
|
|
41
|
+
/** 是否自动导入模块菜单 */
|
|
42
|
+
initMenu?: boolean;
|
|
43
|
+
/** 判断是否初始化的方式 */
|
|
44
|
+
initJudge: 'file' | 'db';
|
|
45
|
+
/** crud配置 */
|
|
46
|
+
crud?: {
|
|
47
|
+
/** 软删除 */
|
|
48
|
+
softDelete: boolean;
|
|
49
|
+
/** 分页查询每页条数 */
|
|
50
|
+
pageSize: number;
|
|
51
|
+
/** 插入方式 */
|
|
52
|
+
upsert: 'normal' | 'save';
|
|
53
|
+
};
|
|
54
|
+
/** elasticsearch配置 */
|
|
55
|
+
es?: {
|
|
56
|
+
nodes: string[];
|
|
57
|
+
options?: any;
|
|
58
|
+
};
|
|
59
|
+
/** pay */
|
|
60
|
+
pay?: {
|
|
61
|
+
/** 微信支付 */
|
|
62
|
+
wx?: HlwWxPayConfig;
|
|
63
|
+
/** 支付宝支付 */
|
|
64
|
+
ali?: HlwAliPayConfig;
|
|
65
|
+
};
|
|
66
|
+
/** rpc */
|
|
67
|
+
rpc?: HlwRpcConfig;
|
|
68
|
+
/** redis */
|
|
69
|
+
redis?: RedisConfig | RedisConfig[];
|
|
70
|
+
/** 文件上传 */
|
|
71
|
+
file?: {
|
|
72
|
+
/** 上传模式 */
|
|
73
|
+
mode: MODETYPE;
|
|
74
|
+
/** 本地上传 文件地址前缀 */
|
|
75
|
+
domain?: string;
|
|
76
|
+
/** oss */
|
|
77
|
+
oss?: OSSConfig;
|
|
78
|
+
/** cos */
|
|
79
|
+
cos?: COSConfig;
|
|
80
|
+
/** qiniu */
|
|
81
|
+
qiniu?: QINIUConfig;
|
|
82
|
+
/** aws */
|
|
83
|
+
aws: AWSConfig;
|
|
84
|
+
};
|
|
85
|
+
/** IOT 配置 */
|
|
86
|
+
iot?: HlwIotConfig;
|
|
87
|
+
}
|
|
88
|
+
export interface HlwRpcConfig {
|
|
89
|
+
/** 服务名称 */
|
|
90
|
+
name: string;
|
|
91
|
+
/** redis */
|
|
92
|
+
redis: RedisConfig & RedisConfig[] & unknown;
|
|
93
|
+
}
|
|
94
|
+
export interface RedisConfig {
|
|
95
|
+
/** host */
|
|
96
|
+
host: string;
|
|
97
|
+
/** password */
|
|
98
|
+
password: string;
|
|
99
|
+
/** port */
|
|
100
|
+
port: number;
|
|
101
|
+
/** db */
|
|
102
|
+
db: number;
|
|
103
|
+
}
|
|
104
|
+
export declare enum MODETYPE {
|
|
105
|
+
/** 本地 */
|
|
106
|
+
LOCAL = "local",
|
|
107
|
+
/** 云存储 */
|
|
108
|
+
CLOUD = "cloud",
|
|
109
|
+
/** 其他 */
|
|
110
|
+
OTHER = "other"
|
|
111
|
+
}
|
|
112
|
+
export declare enum CLOUDTYPE {
|
|
113
|
+
/** 阿里云存储 */
|
|
114
|
+
OSS = "oss",
|
|
115
|
+
/** 腾讯云存储 */
|
|
116
|
+
COS = "cos",
|
|
117
|
+
/** 七牛云存储 */
|
|
118
|
+
QINIU = "qiniu",
|
|
119
|
+
/** AWS S3 */
|
|
120
|
+
AWS = "aws"
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 上传模式
|
|
124
|
+
*/
|
|
125
|
+
export interface Mode {
|
|
126
|
+
/** 模式 */
|
|
127
|
+
mode: MODETYPE;
|
|
128
|
+
/** 类型 */
|
|
129
|
+
type: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 模块配置
|
|
133
|
+
*/
|
|
134
|
+
export interface HlwFileConfig {
|
|
135
|
+
/** 上传模式 */
|
|
136
|
+
mode: MODETYPE;
|
|
137
|
+
/** 阿里云oss 配置 */
|
|
138
|
+
oss: OSSConfig;
|
|
139
|
+
/** 腾讯云 cos配置 */
|
|
140
|
+
cos: COSConfig;
|
|
141
|
+
/** 七牛云 配置 */
|
|
142
|
+
qiniu: QINIUConfig;
|
|
143
|
+
/** AWS s3 配置 */
|
|
144
|
+
aws: AWSConfig;
|
|
145
|
+
/** 文件前缀 */
|
|
146
|
+
domain: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* OSS 配置
|
|
150
|
+
*/
|
|
151
|
+
export interface OSSConfig {
|
|
152
|
+
/** 阿里云accessKeyId */
|
|
153
|
+
accessKeyId: string;
|
|
154
|
+
/** 阿里云accessKeySecret */
|
|
155
|
+
accessKeySecret: string;
|
|
156
|
+
/** 阿里云oss的bucket */
|
|
157
|
+
bucket: string;
|
|
158
|
+
/** 阿里云oss的endpoint */
|
|
159
|
+
endpoint: string;
|
|
160
|
+
/** 阿里云oss的timeout */
|
|
161
|
+
timeout: string;
|
|
162
|
+
/** 签名失效时间,毫秒 */
|
|
163
|
+
expAfter?: number;
|
|
164
|
+
/** 文件最大的 size */
|
|
165
|
+
maxSize?: number;
|
|
166
|
+
host?: string;
|
|
167
|
+
publicDomain?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* COS 配置
|
|
171
|
+
*/
|
|
172
|
+
export interface COSConfig {
|
|
173
|
+
/** 腾讯云accessKeyId */
|
|
174
|
+
accessKeyId: string;
|
|
175
|
+
/** 腾讯云accessKeySecret */
|
|
176
|
+
accessKeySecret: string;
|
|
177
|
+
/** 腾讯云cos的bucket */
|
|
178
|
+
bucket: string;
|
|
179
|
+
/** 腾讯云cos的区域 */
|
|
180
|
+
region: string;
|
|
181
|
+
/** 腾讯云cos的公网访问地址 */
|
|
182
|
+
publicDomain: string;
|
|
183
|
+
/** 上传持续时间 */
|
|
184
|
+
durationSeconds?: number;
|
|
185
|
+
/** 允许操作(上传)的对象前缀 */
|
|
186
|
+
allowPrefix?: string;
|
|
187
|
+
/** 密钥的权限列表 */
|
|
188
|
+
allowActions?: string[];
|
|
189
|
+
}
|
|
190
|
+
export interface QINIUConfig {
|
|
191
|
+
/** 七牛云accessKeyId */
|
|
192
|
+
accessKeyId: string;
|
|
193
|
+
/** 七牛云accessKeySecret */
|
|
194
|
+
accessKeySecret: string;
|
|
195
|
+
/** 七牛云cos的bucket */
|
|
196
|
+
bucket: string;
|
|
197
|
+
/** 七牛云cos的区域 */
|
|
198
|
+
region: string;
|
|
199
|
+
/** 七牛云cos的公网访问地址 */
|
|
200
|
+
publicDomain: string;
|
|
201
|
+
/** 上传地址 */
|
|
202
|
+
uploadUrl?: string;
|
|
203
|
+
/** 上传fileKey */
|
|
204
|
+
fileKey?: string;
|
|
205
|
+
}
|
|
206
|
+
export interface AWSConfig {
|
|
207
|
+
/** accessKeyId */
|
|
208
|
+
accessKeyId: string;
|
|
209
|
+
/** secretAccessKey */
|
|
210
|
+
secretAccessKey: string;
|
|
211
|
+
/** bucket */
|
|
212
|
+
bucket: string;
|
|
213
|
+
/** region */
|
|
214
|
+
region: string;
|
|
215
|
+
/** fields */
|
|
216
|
+
fields?: any;
|
|
217
|
+
/** conditions */
|
|
218
|
+
conditions?: any[];
|
|
219
|
+
/** expires */
|
|
220
|
+
expires?: number;
|
|
221
|
+
/** publicDomain */
|
|
222
|
+
publicDomain?: string;
|
|
223
|
+
/** forcePathStyle */
|
|
224
|
+
forcePathStyle?: boolean;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 微信支付配置
|
|
228
|
+
*/
|
|
229
|
+
export interface HlwWxPayConfig {
|
|
230
|
+
/** 直连商户申请的公众号或移动应用appid。 */
|
|
231
|
+
appid: string;
|
|
232
|
+
/** 商户号 */
|
|
233
|
+
mchid: string;
|
|
234
|
+
/** 可选参数 证书序列号 */
|
|
235
|
+
serial_no?: string;
|
|
236
|
+
/** 回调链接 */
|
|
237
|
+
notify_url: string;
|
|
238
|
+
/** 公钥 */
|
|
239
|
+
publicKey: Buffer;
|
|
240
|
+
/** 私钥 */
|
|
241
|
+
privateKey: Buffer;
|
|
242
|
+
/** 可选参数 认证类型,目前为WECHATPAY2-SHA256-RSA2048 */
|
|
243
|
+
authType?: string;
|
|
244
|
+
/** 可选参数 User-Agent */
|
|
245
|
+
userAgent?: string;
|
|
246
|
+
/** 可选参数 APIv3密钥 */
|
|
247
|
+
key?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 支付宝支付配置
|
|
251
|
+
*/
|
|
252
|
+
export interface HlwAliPayConfig {
|
|
253
|
+
/** 支付回调地址 */
|
|
254
|
+
notifyUrl: string;
|
|
255
|
+
/** 应用ID */
|
|
256
|
+
appId: string;
|
|
257
|
+
/**
|
|
258
|
+
* 应用私钥字符串
|
|
259
|
+
* RSA签名验签工具:https://docs.open.alipay.com/291/106097)
|
|
260
|
+
* 密钥格式一栏请选择 “PKCS1(非JAVA适用)”
|
|
261
|
+
*/
|
|
262
|
+
privateKey: string;
|
|
263
|
+
/** 签名类型 */
|
|
264
|
+
signType?: 'RSA2' | 'RSA';
|
|
265
|
+
/** 支付宝公钥(需要对返回值做验签时候必填) */
|
|
266
|
+
alipayPublicKey?: string;
|
|
267
|
+
/** 网关 */
|
|
268
|
+
gateway?: string;
|
|
269
|
+
/** 网关超时时间(单位毫秒,默认 5s) */
|
|
270
|
+
timeout?: number;
|
|
271
|
+
/** 是否把网关返回的下划线 key 转换为驼峰写法 */
|
|
272
|
+
camelcase?: boolean;
|
|
273
|
+
/** 编码(只支持 utf-8) */
|
|
274
|
+
charset?: 'utf-8';
|
|
275
|
+
/** api版本 */
|
|
276
|
+
version?: '1.0';
|
|
277
|
+
urllib?: any;
|
|
278
|
+
/** 指定private key类型, 默认: PKCS1, PKCS8: PRIVATE KEY, PKCS1: RSA PRIVATE KEY */
|
|
279
|
+
keyType?: 'PKCS1' | 'PKCS8';
|
|
280
|
+
/** 应用公钥证书文件路径 */
|
|
281
|
+
appCertPath?: string;
|
|
282
|
+
/** 应用公钥证书文件内容 */
|
|
283
|
+
appCertContent?: string | Buffer;
|
|
284
|
+
/** 应用公钥证书sn */
|
|
285
|
+
appCertSn?: string;
|
|
286
|
+
/** 支付宝根证书文件路径 */
|
|
287
|
+
alipayRootCertPath?: string;
|
|
288
|
+
/** 支付宝根证书文件内容 */
|
|
289
|
+
alipayRootCertContent?: string | Buffer;
|
|
290
|
+
/** 支付宝根证书sn */
|
|
291
|
+
alipayRootCertSn?: string;
|
|
292
|
+
/** 支付宝公钥证书文件路径 */
|
|
293
|
+
alipayPublicCertPath?: string;
|
|
294
|
+
/** 支付宝公钥证书文件内容 */
|
|
295
|
+
alipayPublicCertContent?: string | Buffer;
|
|
296
|
+
/** 支付宝公钥证书sn */
|
|
297
|
+
alipayCertSn?: string;
|
|
298
|
+
/** AES密钥,调用AES加解密相关接口时需要 */
|
|
299
|
+
encryptKey?: string;
|
|
300
|
+
/** 服务器地址 */
|
|
301
|
+
wsServiceUrl?: string;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* IOT配置
|
|
305
|
+
*/
|
|
306
|
+
export interface HlwIotConfig {
|
|
307
|
+
/** MQTT服务端口 */
|
|
308
|
+
port: number;
|
|
309
|
+
/** MQTT Websocket服务端口 */
|
|
310
|
+
wsPort: number;
|
|
311
|
+
/** redis 配置 mqtt cluster下必须要配置 */
|
|
312
|
+
redis?: {
|
|
313
|
+
/** host */
|
|
314
|
+
host: string;
|
|
315
|
+
/** port */
|
|
316
|
+
port: number;
|
|
317
|
+
/** password */
|
|
318
|
+
password: string;
|
|
319
|
+
/** db */
|
|
320
|
+
db: number;
|
|
321
|
+
};
|
|
322
|
+
/** 发布消息配置 */
|
|
323
|
+
publish?: PublishPacket;
|
|
324
|
+
/** 认证 */
|
|
325
|
+
auth?: {
|
|
326
|
+
/** 用户 */
|
|
327
|
+
username: string;
|
|
328
|
+
/** 密码 */
|
|
329
|
+
password: string;
|
|
330
|
+
};
|
|
331
|
+
/** 服务配置 */
|
|
332
|
+
serve?: AedesOptions;
|
|
333
|
+
}
|
|
334
|
+
export interface HlwSmsConfig {
|
|
335
|
+
/**
|
|
336
|
+
* 阿里云短信配置
|
|
337
|
+
*/
|
|
338
|
+
ali: HlwSmsAliConfig;
|
|
339
|
+
/**
|
|
340
|
+
* 腾讯云短信配置
|
|
341
|
+
*/
|
|
342
|
+
tx: HlwSmsTxConfig;
|
|
343
|
+
/**
|
|
344
|
+
* 云片短信配置
|
|
345
|
+
*/
|
|
346
|
+
yp: HlwSmsYpConfig;
|
|
347
|
+
/**
|
|
348
|
+
* aws短信配置
|
|
349
|
+
*/
|
|
350
|
+
aws: HlwSmsAwsConfig;
|
|
351
|
+
}
|
|
352
|
+
export interface HlwSmsAwsConfig {
|
|
353
|
+
/**
|
|
354
|
+
* 区域
|
|
355
|
+
*/
|
|
356
|
+
region: string;
|
|
357
|
+
/**
|
|
358
|
+
* accessKeyId
|
|
359
|
+
*/
|
|
360
|
+
accessKeyId: string;
|
|
361
|
+
/**
|
|
362
|
+
* secretAccessKey
|
|
363
|
+
*/
|
|
364
|
+
secretAccessKey: string;
|
|
365
|
+
/**
|
|
366
|
+
* 扩展配置
|
|
367
|
+
*/
|
|
368
|
+
extend?: any;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* 阿里云配置
|
|
372
|
+
*/
|
|
373
|
+
export interface HlwSmsAliConfig {
|
|
374
|
+
/**
|
|
375
|
+
* 阿里云accessKeyId
|
|
376
|
+
*/
|
|
377
|
+
accessKeyId: string;
|
|
378
|
+
/**
|
|
379
|
+
* 阿里云accessKeySecret
|
|
380
|
+
*/
|
|
381
|
+
accessKeySecret: string;
|
|
382
|
+
/**
|
|
383
|
+
* 签名,非必填,调用时可以传入
|
|
384
|
+
*/
|
|
385
|
+
signName?: string;
|
|
386
|
+
/**
|
|
387
|
+
* 模板,非必填,调用时可以传入
|
|
388
|
+
*/
|
|
389
|
+
template?: string;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 腾讯云配置
|
|
393
|
+
*/
|
|
394
|
+
export interface HlwSmsTxConfig {
|
|
395
|
+
/**
|
|
396
|
+
* 应用ID
|
|
397
|
+
*/
|
|
398
|
+
appId: string;
|
|
399
|
+
/**
|
|
400
|
+
* 腾讯云secretId
|
|
401
|
+
*/
|
|
402
|
+
secretId: string;
|
|
403
|
+
/**
|
|
404
|
+
* 腾讯云secretKey
|
|
405
|
+
*/
|
|
406
|
+
secretKey: string;
|
|
407
|
+
/**
|
|
408
|
+
* 签名,非必填,调用时可以传入
|
|
409
|
+
*/
|
|
410
|
+
signName?: string;
|
|
411
|
+
/**
|
|
412
|
+
* 模板,非必填,调用时可以传入
|
|
413
|
+
*/
|
|
414
|
+
template?: string;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* 云片短信配置
|
|
418
|
+
*/
|
|
419
|
+
export interface HlwSmsYpConfig {
|
|
420
|
+
/**
|
|
421
|
+
* 云片apikey
|
|
422
|
+
*/
|
|
423
|
+
apikey: string;
|
|
424
|
+
/**
|
|
425
|
+
* 签名,非必填,调用时可以传入
|
|
426
|
+
*/
|
|
427
|
+
signName?: string;
|
|
428
|
+
/**
|
|
429
|
+
* 模板,非必填,调用时可以传入
|
|
430
|
+
*/
|
|
431
|
+
template?: string;
|
|
432
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CLOUDTYPE = exports.MODETYPE = void 0;
|
|
4
|
+
// 模式
|
|
5
|
+
var MODETYPE;
|
|
6
|
+
(function (MODETYPE) {
|
|
7
|
+
/** 本地 */
|
|
8
|
+
MODETYPE["LOCAL"] = "local";
|
|
9
|
+
/** 云存储 */
|
|
10
|
+
MODETYPE["CLOUD"] = "cloud";
|
|
11
|
+
/** 其他 */
|
|
12
|
+
MODETYPE["OTHER"] = "other";
|
|
13
|
+
})(MODETYPE || (exports.MODETYPE = MODETYPE = {}));
|
|
14
|
+
var CLOUDTYPE;
|
|
15
|
+
(function (CLOUDTYPE) {
|
|
16
|
+
/** 阿里云存储 */
|
|
17
|
+
CLOUDTYPE["OSS"] = "oss";
|
|
18
|
+
/** 腾讯云存储 */
|
|
19
|
+
CLOUDTYPE["COS"] = "cos";
|
|
20
|
+
/** 七牛云存储 */
|
|
21
|
+
CLOUDTYPE["QINIU"] = "qiniu";
|
|
22
|
+
/** AWS S3 */
|
|
23
|
+
CLOUDTYPE["AWS"] = "aws";
|
|
24
|
+
})(CLOUDTYPE || (exports.CLOUDTYPE = CLOUDTYPE = {}));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IMidwayApplication } from '@midwayjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* 模块配置
|
|
4
|
+
*/
|
|
5
|
+
export declare class HlwModuleConfig {
|
|
6
|
+
app: IMidwayApplication;
|
|
7
|
+
allConfig: any;
|
|
8
|
+
modules: any;
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* 模块配置
|
|
12
|
+
* @param module 模块
|
|
13
|
+
* @param config 配置
|
|
14
|
+
*/
|
|
15
|
+
moduleConfig(module: any, config: any): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* 全局中间件
|
|
18
|
+
* @param middleware 中间件
|
|
19
|
+
*/
|
|
20
|
+
globalMiddlewareArr(middlewares: any[]): Promise<void>;
|
|
21
|
+
}
|