@jayfong/x-server 2.12.7 → 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 (84) 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 +14 -299
  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.d.ts +3 -130
  72. package/lib/services/request.js +5 -274
  73. package/lib/services/sensitive_words.js +13 -15
  74. package/package.json +4 -28
  75. package/README.md +0 -51
  76. package/lib/_cjs/cli/register.js +0 -8
  77. package/lib/_cjs/client_helper.js +0 -26
  78. package/lib/_cjs/types/_formstream.js +0 -1
  79. package/lib/cli/register.d.ts +0 -1
  80. package/lib/cli/register.js +0 -5
  81. package/lib/client_helper.d.ts +0 -1
  82. package/lib/client_helper.js +0 -16
  83. package/lib/types/_formstream.d.ts +0 -49
  84. package/lib/types/_formstream.js +0 -0
@@ -4,32 +4,24 @@ export class RateLimitService {
4
4
  constructor() {
5
5
  this.serviceName = 'rateLimit';
6
6
  }
7
-
8
7
  async limitByCount(options) {
9
8
  const cacheKey = `rateLimit_${options.key}`;
10
9
  const remainingCount = await x.cache.get(cacheKey);
11
-
12
10
  if (remainingCount == null) {
13
11
  await x.cache.set(cacheKey, options.count, options.ttl);
14
12
  return options.count;
15
13
  }
16
-
17
14
  if (remainingCount === 0) {
18
15
  return 0;
19
16
  }
20
-
21
17
  await x.cache.decrease(cacheKey);
22
18
  return remainingCount - 1;
23
19
  }
24
-
25
20
  async limitByCountOrFail(options) {
26
21
  const count = await this.limitByCount(options);
27
-
28
22
  if (count === 0) {
29
23
  throw new HttpError.Forbidden(options.message);
30
24
  }
31
-
32
25
  return count;
33
26
  }
34
-
35
27
  }
@@ -4,5 +4,4 @@ export class RedisService extends Redis {
4
4
  super(...args);
5
5
  this.serviceName = 'redis';
6
6
  }
7
-
8
7
  }
@@ -1,135 +1,8 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import FormData from 'form-data';
4
- import FormStream from 'formstream';
5
- import Request from 'got/dist/source/core';
6
1
  import { BaseService } from './base';
7
- import { CookieJar } from 'tough-cookie';
8
- import { OmitStrict } from 'vtils/types';
9
- import { Readable } from 'stream';
10
- export interface RequestServiceOptions {
11
- /**
12
- * 请求地址
13
- */
14
- url: string;
15
- /**
16
- * 代理地址
17
- */
18
- proxyUrl?: string;
19
- /**
20
- * 超时毫秒数
21
- */
22
- timeoutMs?: number;
23
- /**
24
- * 头
25
- */
26
- headers?: Record<string, any>;
27
- /**
28
- * 是否跟随跳转
29
- *
30
- * @default true
31
- */
32
- followRedirect?: boolean;
33
- /**
34
- * COOKIE 容器
35
- */
36
- cookieJar?: CookieJar;
37
- /**
38
- * 用户代理
39
- *
40
- * @default "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
41
- */
42
- userAgent?: string;
43
- /**
44
- * 是否自动设置来源地址,设为 true 后若未手动设置来源页则将把请求地址设为来源地址
45
- *
46
- * @default false
47
- */
48
- autoReferer?: boolean;
49
- }
50
- export interface RequestServiceResponse<T> {
51
- status: number;
52
- headers: Record<string, any>;
53
- data: T;
54
- }
55
- export interface RequestServiceGetOptions extends RequestServiceOptions {
56
- data?: Record<string, any>;
57
- }
58
- export interface RequestServicePostOptions extends RequestServiceOptions {
59
- data?: Record<string, any> | FormData | URLSearchParams;
60
- }
61
- export interface RequestServiceGetStreamOptions extends RequestServiceOptions {
62
- data?: Record<string, any>;
63
- }
64
- export interface RequestServicePostStreamOptions extends RequestServiceOptions {
65
- data?: Record<string, any> | FormData | URLSearchParams | FormStream;
66
- }
67
- export declare class RequestFormUrlencoded extends URLSearchParams {
68
- }
69
- export declare class RequestFormData extends FormData {
70
- constructor(cbOrObject?: ((formData: FormData) => FormData) | Record<string, any>);
71
- }
72
- export declare class RequestFormStream extends FormStream {
73
- constructor(cbOrObject?: ((formStream: FormStream) => FormStream) | Record<string, any>);
74
- }
75
- export declare class RequestFormFile {
76
- file: any;
77
- options?: {
78
- name?: string;
79
- type?: string;
80
- };
81
- constructor(file: Buffer, options: {
82
- name: string;
83
- type?: string;
84
- });
85
- constructor(file: Readable, options: {
86
- name: string;
87
- type?: string;
88
- });
89
- constructor(file: string, options?: {
90
- name?: string;
91
- type?: string;
92
- });
93
- }
94
- export declare class RequestService implements BaseService {
95
- private options?;
2
+ import { XRequest } from '@jayfong/x-request';
3
+ export * from '@jayfong/x-request';
4
+ export declare class RequestService extends XRequest implements BaseService {
96
5
  serviceName: string;
97
- private static getGotOptions;
98
- static getRaw(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<Buffer>>;
99
- static getRaw(options: RequestServiceGetStreamOptions, responseType: 'buffer'): Promise<RequestServiceResponse<Buffer>>;
100
- static getRaw(options: RequestServiceGetStreamOptions, responseType: 'text'): Promise<RequestServiceResponse<string>>;
101
- static getRaw<T>(options: RequestServiceGetStreamOptions, responseType: 'json'): Promise<RequestServiceResponse<T>>;
102
- static getRaw(options: RequestServiceGetStreamOptions, responseType: 'stream'): Request;
103
- static postRaw(options: RequestServicePostOptions): Promise<RequestServiceResponse<Buffer>>;
104
- static postRaw(options: RequestServicePostOptions, responseType: 'buffer'): Promise<RequestServiceResponse<Buffer>>;
105
- static postRaw(options: RequestServicePostOptions, responseType: 'text'): Promise<RequestServiceResponse<string>>;
106
- static postRaw<T>(options: RequestServicePostOptions, responseType: 'json'): Promise<RequestServiceResponse<T>>;
107
- static postRaw(options: RequestServicePostOptions, responseType: 'stream'): Request;
108
- static getText(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<string>>;
109
- static postText(options: RequestServicePostOptions): Promise<RequestServiceResponse<string>>;
110
- static get<T>(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<T>>;
111
- static post<T>(options: RequestServicePostOptions): Promise<RequestServiceResponse<T>>;
112
- static getStream(options: RequestServiceGetOptions): Request;
113
- static postStream(options: RequestServicePostStreamOptions): Request;
114
- static isTimeoutError(err: any): boolean;
115
- constructor(options?: OmitStrict<RequestServiceOptions, 'url'>);
116
- getRaw(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<Buffer>>;
117
- getRaw(options: RequestServiceGetStreamOptions, responseType: 'buffer'): Promise<RequestServiceResponse<Buffer>>;
118
- getRaw(options: RequestServiceGetStreamOptions, responseType: 'text'): Promise<RequestServiceResponse<string>>;
119
- getRaw<T>(options: RequestServiceGetStreamOptions, responseType: 'json'): Promise<RequestServiceResponse<T>>;
120
- getRaw(options: RequestServiceGetStreamOptions, responseType: 'stream'): Request;
121
- postRaw(options: RequestServicePostOptions): Promise<RequestServiceResponse<Buffer>>;
122
- postRaw(options: RequestServicePostOptions, responseType: 'buffer'): Promise<RequestServiceResponse<Buffer>>;
123
- postRaw(options: RequestServicePostOptions, responseType: 'text'): Promise<RequestServiceResponse<string>>;
124
- postRaw<T>(options: RequestServicePostOptions, responseType: 'json'): Promise<RequestServiceResponse<T>>;
125
- postRaw(options: RequestServicePostOptions, responseType: 'stream'): Request;
126
- getText(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<string>>;
127
- postText(options: RequestServicePostOptions): Promise<RequestServiceResponse<string>>;
128
- get<T>(options: RequestServiceGetStreamOptions): Promise<RequestServiceResponse<T>>;
129
- post<T>(options: RequestServicePostOptions): Promise<RequestServiceResponse<T>>;
130
- getStream(options: RequestServiceGetOptions): Request;
131
- postStream(options: RequestServicePostStreamOptions): Request;
132
- isTimeoutError(err: any): boolean;
133
6
  }
134
7
  declare module '../x' {
135
8
  interface X {
@@ -1,277 +1,8 @@
1
- import assert from 'assert';
2
- import FormData from 'form-data';
3
- import FormStream from 'formstream';
4
- import fs from 'fs';
5
- import got from 'got';
6
- import { mapKeys } from 'vtils';
7
- import { ProxyAgent } from 'proxy-agent';
8
- import { Readable } from 'stream';
9
- export class RequestFormUrlencoded extends URLSearchParams {}
10
- export class RequestFormData extends FormData {
11
- constructor(cbOrObject) {
12
- super();
13
-
14
- if (cbOrObject) {
15
- if (typeof cbOrObject === 'function') {
16
- cbOrObject(this);
17
- } else {
18
- Object.keys(cbOrObject).forEach(key => {
19
- const value = cbOrObject[key];
20
-
21
- if (value instanceof RequestFormFile) {
22
- var _value$options, _value$options2;
23
-
24
- this.append(key, typeof value.file === 'string' ? fs.createReadStream(value.file) : value.file, {
25
- filename: (_value$options = value.options) == null ? void 0 : _value$options.name,
26
- contentType: (_value$options2 = value.options) == null ? void 0 : _value$options2.type
27
- });
28
- } else {
29
- this.append(key, value);
30
- }
31
- });
32
- }
33
- }
34
- }
35
-
36
- }
37
- export class RequestFormStream extends FormStream {
38
- constructor(cbOrObject) {
39
- super();
40
-
41
- if (cbOrObject) {
42
- if (typeof cbOrObject === 'function') {
43
- cbOrObject(this);
44
- } else {
45
- Object.keys(cbOrObject).forEach(key => {
46
- const value = cbOrObject[key];
47
-
48
- if (value instanceof RequestFormFile) {
49
- if (typeof value.file === 'string') {
50
- var _value$options3;
51
-
52
- this.file(key, value.file, (_value$options3 = value.options) == null ? void 0 : _value$options3.name);
53
- } else if (Buffer.isBuffer(value.file)) {
54
- this.buffer(key, value.file, value.options.name, value.options.type);
55
- } else if (value.file instanceof Readable) {
56
- this.stream(key, value.file, value.options.name, value.options.type);
57
- }
58
- } else {
59
- this.field(key, value);
60
- }
61
- });
62
- }
63
- }
64
- }
65
-
66
- }
67
- export class RequestFormFile {
68
- constructor(file, options) {
69
- this.file = file;
70
- this.options = options;
71
-
72
- if (Buffer.isBuffer(file) || file instanceof Readable) {
73
- assert(options == null ? void 0 : options.name, 'options.name is required');
74
- }
75
- }
76
-
77
- }
78
- export class RequestService {
79
- static getGotOptions(options, responseType) {
80
- var _gotOptions$headers, _userAgent, _gotOptions$headers$_, _options$userAgent;
81
-
82
- const gotOptions = {
83
- url: options.url,
84
- responseType: responseType === 'stream' ? undefined : responseType,
85
- https: {
86
- rejectUnauthorized: false
87
- },
88
- isStream: responseType === 'stream'
89
- };
90
-
91
- if (options.headers) {
92
- gotOptions.headers = options.headers;
93
- }
94
-
95
- if (options.followRedirect != null) {
96
- gotOptions.followRedirect = options.followRedirect;
97
- }
98
-
99
- if (options.timeoutMs) {
100
- gotOptions.timeout = options.timeoutMs;
101
- }
102
-
103
- if (options.proxyUrl) {
104
- const proxyAgent = new ProxyAgent({
105
- getProxyForUrl: () => options.proxyUrl
106
- });
107
- gotOptions.agent = {
108
- http: proxyAgent,
109
- https: proxyAgent,
110
- http2: proxyAgent
111
- };
112
- }
113
-
114
- if (options.cookieJar) {
115
- gotOptions.cookieJar = options.cookieJar;
116
- } // 头处理
117
-
118
-
119
- gotOptions.headers = mapKeys(gotOptions.headers || {}, (v, k) => k.toLowerCase());
120
- (_gotOptions$headers$_ = (_gotOptions$headers = gotOptions.headers)[_userAgent = 'user-agent']) != null ? _gotOptions$headers$_ : _gotOptions$headers[_userAgent] = (_options$userAgent = options.userAgent) != null ? _options$userAgent : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36';
121
-
122
- if (options.autoReferer && gotOptions.headers['referer'] == null) {
123
- gotOptions.headers['referer'] = options.url;
124
- }
125
-
126
- return gotOptions;
127
- }
128
-
129
- static getRaw(options, responseType) {
130
- let url = options.url;
131
-
132
- if (options.data) {
133
- const _url = new URL(url);
134
-
135
- Object.keys(options.data).forEach(key => {
136
- _url.searchParams.set(key, options.data[key]);
137
- });
138
- url = _url.toString();
139
- }
140
-
141
- options.url = url;
142
- const res = got({
143
- method: 'GET',
144
- ...this.getGotOptions(options, responseType || 'buffer')
145
- });
146
-
147
- if (responseType === 'stream') {
148
- return res;
149
- }
150
-
151
- return res.then(res => ({
152
- status: res.statusCode,
153
- headers: res.headers,
154
- data: res.body
155
- }));
156
- }
157
-
158
- static postRaw(options, responseType) {
159
- const gotOptions = this.getGotOptions(options, responseType || 'buffer');
160
-
161
- if (responseType === 'stream' && options.data instanceof FormStream) {
162
- gotOptions.headers = options.data.headers(gotOptions.headers);
163
- }
164
-
165
- const res = got({
166
- method: 'POST',
167
- ...(options.data == null ? {
168
- body: ''
169
- } : options.data instanceof FormData ? {
170
- body: options.data
171
- } : options.data instanceof URLSearchParams ? {
172
- form: options.data
173
- } : options.data instanceof FormStream ? {} : {
174
- json: options.data
175
- }),
176
- ...gotOptions
177
- });
178
-
179
- if (responseType === 'stream' && options.data instanceof FormStream) {
180
- options.data.pipe(res);
181
- }
182
-
183
- if (responseType === 'stream') {
184
- return res;
185
- }
186
-
187
- return res.then(res => ({
188
- status: res.statusCode,
189
- headers: res.headers,
190
- data: res.body
191
- }));
192
- }
193
-
194
- static async getText(options) {
195
- return this.getRaw(options, 'text');
196
- }
197
-
198
- static async postText(options) {
199
- return this.postRaw(options, 'text');
200
- }
201
-
202
- static async get(options) {
203
- return this.getRaw(options, 'json');
204
- }
205
-
206
- static async post(options) {
207
- return this.postRaw(options, 'json');
208
- }
209
-
210
- static getStream(options) {
211
- return this.getRaw(options, 'stream');
212
- }
213
-
214
- static postStream(options) {
215
- return this.postRaw(options, 'stream');
216
- }
217
-
218
- static isTimeoutError(err) {
219
- return err instanceof got.TimeoutError;
220
- }
221
-
222
- constructor(options) {
223
- this.options = options;
1
+ import { XRequest } from '@jayfong/x-request';
2
+ export * from '@jayfong/x-request';
3
+ export class RequestService extends XRequest {
4
+ constructor(...args) {
5
+ super(...args);
224
6
  this.serviceName = 'request';
225
7
  }
226
-
227
- getRaw(options, responseType) {
228
- var _this$options;
229
-
230
- return RequestService.getRaw({ ...this.options,
231
- ...options,
232
- headers: { ...((_this$options = this.options) == null ? void 0 : _this$options.headers),
233
- ...options.headers
234
- }
235
- }, responseType);
236
- }
237
-
238
- postRaw(options, responseType) {
239
- var _this$options2;
240
-
241
- return RequestService.postRaw({ ...this.options,
242
- ...options,
243
- headers: { ...((_this$options2 = this.options) == null ? void 0 : _this$options2.headers),
244
- ...options.headers
245
- }
246
- }, responseType);
247
- }
248
-
249
- async getText(options) {
250
- return this.getRaw(options, 'text');
251
- }
252
-
253
- async postText(options) {
254
- return this.postRaw(options, 'text');
255
- }
256
-
257
- async get(options) {
258
- return this.getRaw(options, 'json');
259
- }
260
-
261
- async post(options) {
262
- return this.postRaw(options, 'json');
263
- }
264
-
265
- getStream(options) {
266
- return this.getRaw(options, 'stream');
267
- }
268
-
269
- postStream(options) {
270
- return this.postRaw(options, 'stream');
271
- }
272
-
273
- isTimeoutError(err) {
274
- return RequestService.isTimeoutError(err);
275
- }
276
-
277
8
  }
@@ -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.7",
3
+ "version": "2.12.15",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",
@@ -13,25 +13,17 @@
13
13
  "lib"
14
14
  ],
15
15
  "scripts": {
16
- "bootstrap": "tyn --frozen-lockfile",
17
16
  "build": "haoma compile",
18
17
  "build_test_pkg": "tyn build && rm -rf ./lib_test && mkdir -p ./lib_test && cp -r ./lib ./lib_test/lib && cp ./package.json ./lib_test/package.json && cd ./tests/app && tyn add file:../../lib_test",
19
- "dev": "rm -rf lib && tsc -w -p ./tsconfig.build.json",
20
- "release": "source proxy-use-trojan.sh && tyn test && standard-version -a && tyn build && npm publish && haoma run ./scripts/publish_client_helper_package.ts && git push --follow-tags origin master",
21
18
  "test": "tsc --noEmit -p ./tsconfig.build.json && jest \"$(pwd)/src/\"",
22
- "test_all": "tsc --noEmit -p ./tsconfig.build.json && jest",
23
- "updeps": "tnpx npm-check-updates --target minor --upgrade"
24
- },
25
- "husky": {
26
- "hooks": {
27
- "post-merge": "tyn bootstrap"
28
- }
19
+ "test_all": "tsc --noEmit -p ./tsconfig.build.json && jest"
29
20
  },
30
21
  "dependencies": {
31
22
  "@fastify/cors": "^8.3.0",
32
23
  "@fastify/formbody": "^7.4.0",
33
24
  "@fastify/multipart": "^7.7.0",
34
25
  "@fastify/websocket": "^8.1.0",
26
+ "@jayfong/x-request": "^2.12.15",
35
27
  "@prisma/client": "^4.8.0",
36
28
  "@types/busboy": "^0.3.2",
37
29
  "@types/cron": "^2.0.0",
@@ -49,15 +41,11 @@
49
41
  "cuid": "^2.1.8",
50
42
  "debug": "^4.3.4",
51
43
  "esbuild": "^0.18.11",
52
- "esbuild-register": "^3.4.2",
53
44
  "execa": "^5.1.1",
54
45
  "exit-hook": "^2.2.1",
55
46
  "fast-xml-parser": "^4.2.5",
56
47
  "fastify": "^4.19.2",
57
- "form-data": "^4.0.0",
58
- "formstream": "^1.2.0",
59
48
  "fs-extra": "^10.0.1",
60
- "get-port": "^7.0.0",
61
49
  "globby": "^11",
62
50
  "got": "^11.8.2",
63
51
  "http-errors": "^2.0.0",
@@ -71,11 +59,9 @@
71
59
  "nodemailer": "^6.7.3",
72
60
  "pino-pretty": "^10.0.1",
73
61
  "prisma": "^4.8.0",
74
- "proxy-agent": "^6.2.2",
75
62
  "select-run": "^1.1.2",
76
63
  "supports-color": "^8",
77
64
  "svg-captcha": "^1.4.0",
78
- "tough-cookie": "^4.1.3",
79
65
  "ts-morph": "^12.2.0",
80
66
  "utf-8-validate": "^5.0.9",
81
67
  "vscode-generate-index-standalone": "^1.7.1",
@@ -90,20 +76,10 @@
90
76
  "@types/json-schema": "^7.0.11",
91
77
  "@types/lz-string": "^1.3.34",
92
78
  "axios": "^1.4.0",
93
- "eslint": "^7.32.0",
94
- "haoma": "^3.6.4",
95
- "husky": "^4.3.8",
96
79
  "ioredis-mock": "^8.7.0",
97
- "jest": "^27.5.1",
98
80
  "json-xml-parse": "^1.2.4",
99
- "lint-staged": "^10.5.4",
100
81
  "node-fetch": "^3.3.1",
101
- "npm-check-updates": "^12.5.9",
102
- "prettier": "^2.8.8",
103
- "proxy": "^2.1.1",
104
- "standard-version": "^9.3.2",
105
- "typescript": "^5.1.6",
106
- "typescript-snapshots-plugin": "^1.7.0"
82
+ "npm-check-updates": "^12.5.9"
107
83
  },
108
84
  "publishConfig": {
109
85
  "access": "public"
package/README.md DELETED
@@ -1,51 +0,0 @@
1
- # x-server
2
-
3
- X 服务端。
4
-
5
- ## 技术栈
6
-
7
- - [fastify v3](https://github.com/fastify/fastify)
8
- - [prisma v3](https://github.com/prisma/prisma)
9
-
10
- ## 特性
11
-
12
- - 通过 `cache` 支持 redis 缓存
13
- - 通过 `jwt` 支持用户认证
14
- - 通过 `captcha` 支持验证码
15
- - 通过 `defineHandler` 支持 POST、GET、POST、FILE、WS、XML 请求
16
- - 通过 `defineTask` 支持定时任务
17
-
18
- ## 命令
19
-
20
- ### xs dev
21
-
22
- 开始开发
23
-
24
- - `-i aaa -i bbb`: 额外需要生成的索引文件
25
- - `-npc xxx@bbbb`: npc 地址及密钥,格式:地址@密钥
26
-
27
- ### xs build
28
-
29
- 构建
30
-
31
- - `-e aaa -e bbb`: 不应该被打的包
32
-
33
- ### xs deploy
34
-
35
- 部署
36
-
37
- ### xs api
38
-
39
- 生成 API
40
-
41
- ### xs prisma
42
-
43
- prisma 代理,主要为了注入环境变量
44
-
45
- - `-p false`: 是否生产模式
46
-
47
- ### xs run
48
-
49
- 执行 package.json 里的脚本
50
-
51
- - `-p false`: 是否生产模式
@@ -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
- });