@jayfong/x-server 2.12.14 → 2.12.15
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/lib/_cjs/cli/api_generator.js +20 -54
- package/lib/_cjs/cli/build_util.js +16 -45
- package/lib/_cjs/cli/cli.js +6 -27
- package/lib/_cjs/cli/deploy_util.js +0 -12
- package/lib/_cjs/cli/env_util.js +16 -49
- package/lib/_cjs/cli/template_util.js +26 -29
- package/lib/_cjs/core/define_bus.js +9 -6
- package/lib/_cjs/core/define_cron.js +0 -2
- package/lib/_cjs/core/define_handler.js +10 -12
- package/lib/_cjs/core/define_hook.js +0 -2
- package/lib/_cjs/core/define_server.js +0 -2
- package/lib/_cjs/core/define_task.js +7 -13
- package/lib/_cjs/core/get_handler_url.js +1 -2
- package/lib/_cjs/core/handler.js +8 -29
- package/lib/_cjs/core/http_error.js +0 -3
- package/lib/_cjs/core/http_header.js +8 -12
- package/lib/_cjs/core/server.js +8 -41
- package/lib/_cjs/core/types.js +0 -7
- package/lib/_cjs/index.js +0 -72
- package/lib/_cjs/plugins/cors.js +0 -7
- package/lib/_cjs/plugins/file_parser.js +2 -9
- package/lib/_cjs/plugins/form_body_parser.js +0 -6
- package/lib/_cjs/plugins/ws_parser.js +0 -6
- package/lib/_cjs/plugins/xml_parser.js +0 -12
- package/lib/_cjs/services/cache.js +18 -58
- package/lib/_cjs/services/captcha.js +0 -14
- package/lib/_cjs/services/dingtalk.js +0 -14
- package/lib/_cjs/services/dispose.js +0 -9
- package/lib/_cjs/services/emoji.js +2 -5
- package/lib/_cjs/services/jwt.js +0 -21
- package/lib/_cjs/services/log.js +0 -17
- package/lib/_cjs/services/mail.js +0 -9
- package/lib/_cjs/services/pay.js +9 -40
- package/lib/_cjs/services/rate_limit.js +0 -12
- package/lib/_cjs/services/redis.js +0 -4
- package/lib/_cjs/services/request.js +0 -5
- package/lib/_cjs/services/sensitive_words.js +13 -19
- package/lib/_cjs/x.js +0 -11
- package/lib/cli/api_generator.js +20 -42
- package/lib/cli/build_util.js +16 -19
- package/lib/cli/cli.js +6 -12
- package/lib/cli/deploy_util.js +0 -4
- package/lib/cli/env_util.js +16 -37
- package/lib/cli/template_util.d.ts +1 -0
- package/lib/cli/template_util.js +26 -14
- package/lib/core/define_bus.js +7 -5
- package/lib/core/define_handler.js +10 -9
- package/lib/core/define_task.js +7 -6
- package/lib/core/get_handler_url.js +2 -1
- package/lib/core/handler.js +9 -22
- package/lib/core/http_header.js +6 -9
- package/lib/core/server.js +8 -31
- package/lib/core/types.js +0 -7
- package/lib/index.js +4 -3
- package/lib/plugins/cors.js +0 -3
- package/lib/plugins/file_parser.js +2 -5
- package/lib/plugins/form_body_parser.js +0 -3
- package/lib/plugins/ws_parser.js +0 -3
- package/lib/plugins/xml_parser.js +0 -10
- package/lib/services/cache.js +18 -52
- package/lib/services/captcha.js +0 -7
- package/lib/services/dingtalk.js +0 -7
- package/lib/services/dispose.js +0 -5
- package/lib/services/emoji.js +2 -3
- package/lib/services/jwt.js +0 -13
- package/lib/services/log.js +0 -8
- package/lib/services/mail.js +0 -3
- package/lib/services/pay.js +9 -30
- package/lib/services/rate_limit.js +0 -8
- package/lib/services/redis.js +0 -1
- package/lib/services/request.js +0 -1
- package/lib/services/sensitive_words.js +13 -15
- package/package.json +3 -4
- package/lib/_cjs/cli/register.js +0 -8
- package/lib/cli/register.d.ts +0 -1
- package/lib/cli/register.js +0 -5
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Mint from 'mint-filter';
|
|
2
2
|
import { removeBlankChars, removeNonWordChars, toHalfWidthString } from 'vtils';
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* 敏感词服务。
|
|
6
5
|
*/
|
|
@@ -10,30 +9,32 @@ export class SensitiveWordsService {
|
|
|
10
9
|
this.serviceName = 'sensitiveWords';
|
|
11
10
|
this.mint = void 0;
|
|
12
11
|
}
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* 文本转换。
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
16
|
transform(text) {
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
return (
|
|
18
|
+
// 移除空白字符
|
|
19
|
+
removeBlankChars(
|
|
20
|
+
// 移除非单词字符
|
|
21
|
+
removeNonWordChars(
|
|
22
|
+
// 全角转半角
|
|
23
|
+
toHalfWidthString(text)))
|
|
24
|
+
// 转小写
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
// 叠词归一
|
|
24
27
|
.replace(/(.)\1+/g, '$1')
|
|
25
28
|
);
|
|
26
29
|
}
|
|
30
|
+
|
|
27
31
|
/**
|
|
28
32
|
* 处理文本,敏感词将被替换为 * 号。
|
|
29
33
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
34
|
async process(text) {
|
|
33
35
|
if (!this.mint) {
|
|
34
36
|
this.mint = new Mint(this.options.words);
|
|
35
37
|
}
|
|
36
|
-
|
|
37
38
|
const res = await this.mint.filter(this.transform(text), {
|
|
38
39
|
every: true,
|
|
39
40
|
replace: true,
|
|
@@ -41,16 +42,14 @@ export class SensitiveWordsService {
|
|
|
41
42
|
});
|
|
42
43
|
return res.text;
|
|
43
44
|
}
|
|
45
|
+
|
|
44
46
|
/**
|
|
45
47
|
* 验证文本是否包含敏感词。
|
|
46
48
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
49
|
async validate(text, every) {
|
|
50
50
|
if (!this.mint) {
|
|
51
51
|
this.mint = new Mint(this.options.words);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
53
|
const res = await this.mint.filter(this.transform(text), {
|
|
55
54
|
replace: false,
|
|
56
55
|
every: !!every,
|
|
@@ -61,5 +60,4 @@ export class SensitiveWordsService {
|
|
|
61
60
|
words: res.words
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
|
-
|
|
65
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayfong/x-server",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.15",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "lib/_cjs/index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@fastify/formbody": "^7.4.0",
|
|
24
24
|
"@fastify/multipart": "^7.7.0",
|
|
25
25
|
"@fastify/websocket": "^8.1.0",
|
|
26
|
+
"@jayfong/x-request": "^2.12.15",
|
|
26
27
|
"@prisma/client": "^4.8.0",
|
|
27
28
|
"@types/busboy": "^0.3.2",
|
|
28
29
|
"@types/cron": "^2.0.0",
|
|
@@ -40,7 +41,6 @@
|
|
|
40
41
|
"cuid": "^2.1.8",
|
|
41
42
|
"debug": "^4.3.4",
|
|
42
43
|
"esbuild": "^0.18.11",
|
|
43
|
-
"esbuild-register": "^3.4.2",
|
|
44
44
|
"execa": "^5.1.1",
|
|
45
45
|
"exit-hook": "^2.2.1",
|
|
46
46
|
"fast-xml-parser": "^4.2.5",
|
|
@@ -67,8 +67,7 @@
|
|
|
67
67
|
"vscode-generate-index-standalone": "^1.7.1",
|
|
68
68
|
"vtils": "^4.85.3",
|
|
69
69
|
"yaml": "^2.3.1",
|
|
70
|
-
"yargs": "^17.4.1"
|
|
71
|
-
"@jayfong/x-request": "^2.12.14"
|
|
70
|
+
"yargs": "^17.4.1"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
73
|
"@types/debug": "^4.1.7",
|
package/lib/_cjs/cli/register.js
DELETED
package/lib/cli/register.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|