@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.
Files changed (76) 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 +6 -27
  4. package/lib/_cjs/cli/deploy_util.js +0 -12
  5. package/lib/_cjs/cli/env_util.js +16 -49
  6. package/lib/_cjs/cli/template_util.js +26 -29
  7. package/lib/_cjs/core/define_bus.js +9 -6
  8. package/lib/_cjs/core/define_cron.js +0 -2
  9. package/lib/_cjs/core/define_handler.js +10 -12
  10. package/lib/_cjs/core/define_hook.js +0 -2
  11. package/lib/_cjs/core/define_server.js +0 -2
  12. package/lib/_cjs/core/define_task.js +7 -13
  13. package/lib/_cjs/core/get_handler_url.js +1 -2
  14. package/lib/_cjs/core/handler.js +8 -29
  15. package/lib/_cjs/core/http_error.js +0 -3
  16. package/lib/_cjs/core/http_header.js +8 -12
  17. package/lib/_cjs/core/server.js +8 -41
  18. package/lib/_cjs/core/types.js +0 -7
  19. package/lib/_cjs/index.js +0 -72
  20. package/lib/_cjs/plugins/cors.js +0 -7
  21. package/lib/_cjs/plugins/file_parser.js +2 -9
  22. package/lib/_cjs/plugins/form_body_parser.js +0 -6
  23. package/lib/_cjs/plugins/ws_parser.js +0 -6
  24. package/lib/_cjs/plugins/xml_parser.js +0 -12
  25. package/lib/_cjs/services/cache.js +18 -58
  26. package/lib/_cjs/services/captcha.js +0 -14
  27. package/lib/_cjs/services/dingtalk.js +0 -14
  28. package/lib/_cjs/services/dispose.js +0 -9
  29. package/lib/_cjs/services/emoji.js +2 -5
  30. package/lib/_cjs/services/jwt.js +0 -21
  31. package/lib/_cjs/services/log.js +0 -17
  32. package/lib/_cjs/services/mail.js +0 -9
  33. package/lib/_cjs/services/pay.js +9 -40
  34. package/lib/_cjs/services/rate_limit.js +0 -12
  35. package/lib/_cjs/services/redis.js +0 -4
  36. package/lib/_cjs/services/request.js +0 -5
  37. package/lib/_cjs/services/sensitive_words.js +13 -19
  38. package/lib/_cjs/x.js +0 -11
  39. package/lib/cli/api_generator.js +20 -42
  40. package/lib/cli/build_util.js +16 -19
  41. package/lib/cli/cli.js +6 -12
  42. package/lib/cli/deploy_util.js +0 -4
  43. package/lib/cli/env_util.js +16 -37
  44. package/lib/cli/template_util.d.ts +1 -0
  45. package/lib/cli/template_util.js +26 -14
  46. package/lib/core/define_bus.js +7 -5
  47. package/lib/core/define_handler.js +10 -9
  48. package/lib/core/define_task.js +7 -6
  49. package/lib/core/get_handler_url.js +2 -1
  50. package/lib/core/handler.js +9 -22
  51. package/lib/core/http_header.js +6 -9
  52. package/lib/core/server.js +8 -31
  53. package/lib/core/types.js +0 -7
  54. package/lib/index.js +4 -3
  55. package/lib/plugins/cors.js +0 -3
  56. package/lib/plugins/file_parser.js +2 -5
  57. package/lib/plugins/form_body_parser.js +0 -3
  58. package/lib/plugins/ws_parser.js +0 -3
  59. package/lib/plugins/xml_parser.js +0 -10
  60. package/lib/services/cache.js +18 -52
  61. package/lib/services/captcha.js +0 -7
  62. package/lib/services/dingtalk.js +0 -7
  63. package/lib/services/dispose.js +0 -5
  64. package/lib/services/emoji.js +2 -3
  65. package/lib/services/jwt.js +0 -13
  66. package/lib/services/log.js +0 -8
  67. package/lib/services/mail.js +0 -3
  68. package/lib/services/pay.js +9 -30
  69. package/lib/services/rate_limit.js +0 -8
  70. package/lib/services/redis.js +0 -1
  71. package/lib/services/request.js +0 -1
  72. package/lib/services/sensitive_words.js +13 -15
  73. package/package.json +3 -4
  74. package/lib/_cjs/cli/register.js +0 -8
  75. package/lib/cli/register.d.ts +0 -1
  76. 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
- 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.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",
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- var _node = require("esbuild-register/dist/node");
4
-
5
- (0, _node.register)({
6
- hookIgnoreNodeModules: false,
7
- hookMatcher: filename => filename.includes('/.x/') || !filename.includes('/node_modules/')
8
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { register } from 'esbuild-register/dist/node';
2
- register({
3
- hookIgnoreNodeModules: false,
4
- hookMatcher: filename => filename.includes('/.x/') || !filename.includes('/node_modules/')
5
- });