@jayfong/x-server 1.25.0 → 1.26.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.26.2](https://github.com/jfWorks/x-server/compare/v1.26.1...v1.26.2) (2022-05-03)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * defineTask ([8b32f5c](https://github.com/jfWorks/x-server/commit/8b32f5c4b068ac5c03030901dffa599df4fb6cf6))
11
+
12
+ ### [1.26.1](https://github.com/jfWorks/x-server/compare/v1.26.0...v1.26.1) (2022-05-03)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * defineTask ([7d5a5d2](https://github.com/jfWorks/x-server/commit/7d5a5d247a63301dc46042238a6d31f7f4cb5423))
18
+
19
+ ## [1.26.0](https://github.com/jfWorks/x-server/compare/v1.25.0...v1.26.0) (2022-05-02)
20
+
21
+
22
+ ### Features
23
+
24
+ * add SensitiveWordsService ([ee03592](https://github.com/jfWorks/x-server/commit/ee03592f5acd795b03fa65717ea276db66f453c1))
25
+
5
26
  ## [1.25.0](https://github.com/jfWorks/x-server/compare/v1.24.2...v1.25.0) (2022-05-02)
6
27
 
7
28
 
@@ -9,9 +9,13 @@ var _bull = _interopRequireDefault(require("bull"));
9
9
 
10
10
  var _x = require("../x");
11
11
 
12
- async function defineTask(options) {
12
+ function defineTask(options) {
13
13
  const queue = new _bull.default(options.name, {
14
- redis: _x.x.redis.options,
14
+ redis: { ..._x.x.redis.options,
15
+ // https://github.com/OptimalBits/bull/issues/2186
16
+ maxRetriesPerRequest: null,
17
+ enableReadyCheck: false
18
+ },
15
19
  prefix: `${_x.x.appId}_task`
16
20
  });
17
21
  queue.process(async job => {
package/lib/_cjs/index.js CHANGED
@@ -210,6 +210,14 @@ Object.keys(_redis).forEach(function (key) {
210
210
  exports[key] = _redis[key];
211
211
  });
212
212
 
213
+ var _sensitive_words = require("./services/sensitive_words");
214
+
215
+ Object.keys(_sensitive_words).forEach(function (key) {
216
+ if (key === "default" || key === "__esModule") return;
217
+ if (key in exports && exports[key] === _sensitive_words[key]) return;
218
+ exports[key] = _sensitive_words[key];
219
+ });
220
+
213
221
  var _x = require("./x");
214
222
 
215
223
  Object.keys(_x).forEach(function (key) {
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ exports.__esModule = true;
6
+ exports.SensitiveWordsService = void 0;
7
+
8
+ var _mintFilter = _interopRequireDefault(require("mint-filter"));
9
+
10
+ class SensitiveWordsService {
11
+ constructor(options) {
12
+ this.options = options;
13
+ this.serviceName = 'sensitiveWords';
14
+ this.mint = void 0;
15
+ }
16
+
17
+ async filter(text) {
18
+ if (!this.mint) {
19
+ this.mint = new _mintFilter.default(this.options.words);
20
+ }
21
+
22
+ const res = await this.mint.filter(text, {
23
+ every: true,
24
+ replace: true,
25
+ words: false
26
+ });
27
+ return res.text;
28
+ }
29
+
30
+ }
31
+
32
+ exports.SensitiveWordsService = SensitiveWordsService;
@@ -1,2 +1,2 @@
1
1
  import type { XTask } from './types';
2
- export declare function defineTask<T>(options: XTask.Options<T>): Promise<XTask.Task<T>>;
2
+ export declare function defineTask<T>(options: XTask.Options<T>): XTask.Task<T>;
@@ -1,8 +1,12 @@
1
1
  import Queue from 'bull';
2
2
  import { x } from "../x";
3
- export async function defineTask(options) {
3
+ export function defineTask(options) {
4
4
  const queue = new Queue(options.name, {
5
- redis: x.redis.options,
5
+ redis: { ...x.redis.options,
6
+ // https://github.com/OptimalBits/bull/issues/2186
7
+ maxRetriesPerRequest: null,
8
+ enableReadyCheck: false
9
+ },
6
10
  prefix: `${x.appId}_task`
7
11
  });
8
12
  queue.process(async job => {
package/lib/index.d.ts CHANGED
@@ -24,5 +24,6 @@ export * from './services/mail';
24
24
  export * from './services/pay';
25
25
  export * from './services/rate_limit';
26
26
  export * from './services/redis';
27
+ export * from './services/sensitive_words';
27
28
  export * from './x';
28
29
  export * from '.x/models';
package/lib/index.js CHANGED
@@ -25,6 +25,7 @@ export * from "./services/mail";
25
25
  export * from "./services/pay";
26
26
  export * from "./services/rate_limit";
27
27
  export * from "./services/redis";
28
+ export * from "./services/sensitive_words";
28
29
  export * from "./x"; // @endindex
29
30
  // @ts-ignore
30
31
 
@@ -0,0 +1,16 @@
1
+ import { BaseService } from './base';
2
+ export interface SensitiveWordsOptions {
3
+ words: string[];
4
+ }
5
+ export declare class SensitiveWordsService implements BaseService {
6
+ private options;
7
+ serviceName: string;
8
+ private mint;
9
+ constructor(options: SensitiveWordsOptions);
10
+ filter(text: string): Promise<string>;
11
+ }
12
+ declare module '../x' {
13
+ interface X {
14
+ sensitiveWords: SensitiveWordsService;
15
+ }
16
+ }
@@ -0,0 +1,22 @@
1
+ import Mint from 'mint-filter';
2
+ export class SensitiveWordsService {
3
+ constructor(options) {
4
+ this.options = options;
5
+ this.serviceName = 'sensitiveWords';
6
+ this.mint = void 0;
7
+ }
8
+
9
+ async filter(text) {
10
+ if (!this.mint) {
11
+ this.mint = new Mint(this.options.words);
12
+ }
13
+
14
+ const res = await this.mint.filter(text, {
15
+ every: true,
16
+ replace: true,
17
+ words: false
18
+ });
19
+ return res.text;
20
+ }
21
+
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "1.25.0",
3
+ "version": "1.26.2",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -57,6 +57,7 @@
57
57
  "ioredis": "^4.28.5",
58
58
  "jsonwebtoken": "^8.5.1",
59
59
  "mini-svg-data-uri": "^1.4.4",
60
+ "mint-filter": "^3.0.1",
60
61
  "node-ssh": "^12.0.4",
61
62
  "nodemailer": "^6.7.3",
62
63
  "pino-pretty": "^7.6.1",