@jayfong/x-server 2.12.14 → 2.12.16

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.
Files changed (79) hide show
  1. package/lib/_cjs/cli/api_generator.js +20 -54
  2. package/lib/_cjs/cli/build_util.js +16 -45
  3. package/lib/_cjs/cli/cli.js +17 -29
  4. package/lib/_cjs/cli/deploy_util.js +0 -12
  5. package/lib/_cjs/cli/dev_util.js +18 -0
  6. package/lib/_cjs/cli/env_util.js +16 -49
  7. package/lib/_cjs/cli/{register.js → esbuild_register.js} +0 -1
  8. package/lib/_cjs/cli/template_util.js +26 -29
  9. package/lib/_cjs/core/define_bus.js +9 -6
  10. package/lib/_cjs/core/define_cron.js +0 -2
  11. package/lib/_cjs/core/define_handler.js +10 -12
  12. package/lib/_cjs/core/define_hook.js +0 -2
  13. package/lib/_cjs/core/define_server.js +0 -2
  14. package/lib/_cjs/core/define_task.js +7 -13
  15. package/lib/_cjs/core/get_handler_url.js +1 -2
  16. package/lib/_cjs/core/handler.js +8 -29
  17. package/lib/_cjs/core/http_error.js +0 -3
  18. package/lib/_cjs/core/http_header.js +8 -12
  19. package/lib/_cjs/core/server.js +8 -41
  20. package/lib/_cjs/core/types.js +0 -7
  21. package/lib/_cjs/index.js +0 -72
  22. package/lib/_cjs/plugins/cors.js +0 -7
  23. package/lib/_cjs/plugins/file_parser.js +2 -9
  24. package/lib/_cjs/plugins/form_body_parser.js +0 -6
  25. package/lib/_cjs/plugins/ws_parser.js +0 -6
  26. package/lib/_cjs/plugins/xml_parser.js +0 -12
  27. package/lib/_cjs/services/cache.js +18 -58
  28. package/lib/_cjs/services/captcha.js +0 -14
  29. package/lib/_cjs/services/dingtalk.js +0 -14
  30. package/lib/_cjs/services/dispose.js +0 -9
  31. package/lib/_cjs/services/emoji.js +2 -5
  32. package/lib/_cjs/services/jwt.js +0 -21
  33. package/lib/_cjs/services/log.js +0 -17
  34. package/lib/_cjs/services/mail.js +0 -9
  35. package/lib/_cjs/services/pay.js +9 -40
  36. package/lib/_cjs/services/rate_limit.js +0 -12
  37. package/lib/_cjs/services/redis.js +0 -4
  38. package/lib/_cjs/services/request.js +0 -5
  39. package/lib/_cjs/services/sensitive_words.js +13 -19
  40. package/lib/_cjs/x.js +0 -11
  41. package/lib/cli/api_generator.js +20 -42
  42. package/lib/cli/build_util.js +16 -19
  43. package/lib/cli/cli.js +17 -14
  44. package/lib/cli/deploy_util.js +0 -4
  45. package/lib/cli/dev_util.d.ts +8 -0
  46. package/lib/cli/dev_util.js +12 -0
  47. package/lib/cli/env_util.js +16 -37
  48. package/lib/cli/template_util.d.ts +1 -0
  49. package/lib/cli/template_util.js +26 -14
  50. package/lib/core/define_bus.js +7 -5
  51. package/lib/core/define_handler.js +10 -9
  52. package/lib/core/define_task.js +7 -6
  53. package/lib/core/get_handler_url.js +2 -1
  54. package/lib/core/handler.js +9 -22
  55. package/lib/core/http_header.js +6 -9
  56. package/lib/core/server.js +8 -31
  57. package/lib/core/types.js +0 -7
  58. package/lib/index.js +4 -3
  59. package/lib/plugins/cors.js +0 -3
  60. package/lib/plugins/file_parser.js +2 -5
  61. package/lib/plugins/form_body_parser.js +0 -3
  62. package/lib/plugins/ws_parser.js +0 -3
  63. package/lib/plugins/xml_parser.js +0 -10
  64. package/lib/services/cache.js +18 -52
  65. package/lib/services/captcha.js +0 -7
  66. package/lib/services/dingtalk.js +0 -7
  67. package/lib/services/dispose.js +0 -5
  68. package/lib/services/emoji.js +2 -3
  69. package/lib/services/jwt.js +0 -13
  70. package/lib/services/log.js +0 -8
  71. package/lib/services/mail.js +0 -3
  72. package/lib/services/pay.js +9 -30
  73. package/lib/services/rate_limit.js +0 -8
  74. package/lib/services/redis.js +0 -1
  75. package/lib/services/request.js +0 -1
  76. package/lib/services/sensitive_words.js +13 -15
  77. package/package.json +3 -3
  78. /package/lib/cli/{register.d.ts → esbuild_register.d.ts} +0 -0
  79. /package/lib/cli/{register.js → esbuild_register.js} +0 -0
@@ -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
- removeBlankChars( // 移除非单词字符
21
- removeNonWordChars( // 全角转半角
22
- toHalfWidthString(text))) // 转小写
23
- .toLowerCase() // 叠词归一
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.14",
3
+ "version": "2.12.16",
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.16",
26
27
  "@prisma/client": "^4.8.0",
27
28
  "@types/busboy": "^0.3.2",
28
29
  "@types/cron": "^2.0.0",
@@ -67,8 +68,7 @@
67
68
  "vscode-generate-index-standalone": "^1.7.1",
68
69
  "vtils": "^4.85.3",
69
70
  "yaml": "^2.3.1",
70
- "yargs": "^17.4.1",
71
- "@jayfong/x-request": "^2.12.14"
71
+ "yargs": "^17.4.1"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/debug": "^4.1.7",
File without changes