@jayfong/x-server 1.19.0 → 1.21.0

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.21.0](https://github.com/jfWorks/x-server/compare/v1.20.1...v1.21.0) (2022-04-29)
6
+
7
+
8
+ ### Features
9
+
10
+ * export * from '@prisma/client' ([3e6c707](https://github.com/jfWorks/x-server/commit/3e6c707d55bad0cbb719f1b76bdd306ef0527ba1))
11
+
12
+ ### [1.20.1](https://github.com/jfWorks/x-server/compare/v1.20.0...v1.20.1) (2022-04-27)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * res == null ? ({} as any) : res ([ea0c531](https://github.com/jfWorks/x-server/commit/ea0c531524636cf9a92e43646fb37bd57b6148d7))
18
+
19
+ ## [1.20.0](https://github.com/jfWorks/x-server/compare/v1.19.0...v1.20.0) (2022-04-27)
20
+
21
+
22
+ ### Features
23
+
24
+ * add responseContentType ([dcd9841](https://github.com/jfWorks/x-server/commit/dcd9841e7940d0bc4dfd55faa69deedd1463aee0))
25
+
5
26
  ## [1.19.0](https://github.com/jfWorks/x-server/compare/v1.18.0...v1.19.0) (2022-04-27)
6
27
 
7
28
 
@@ -20,3 +20,5 @@ function makeBaseModel<TModelName extends ModelName>(name: TModelName) {
20
20
 
21
21
  // @index('../.prisma/client/index.d.ts', /(?<=const ModelName:).+?(?=\})/s, /(\S+?):/g, (m, _) => `export const ${_.pascal(m[1])}BaseModel = makeBaseModel('${_.camel(m[1])}')`)
22
22
  // @endindex
23
+
24
+ export * from '@prisma/client'
@@ -43,13 +43,18 @@ class Handler {
43
43
  }
44
44
  }
45
45
 
46
- let res = await this.options.handle(data, ctx); // 打包返回数据
46
+ let res = await this.options.handle(data, ctx); // 设置响应的 Content-Type 头
47
+
48
+ if (this.options.responseContentType) {
49
+ ctx.setHeader('Content-Type', this.options.responseContentType);
50
+ } // 打包返回数据
51
+
47
52
 
48
53
  if (this.options.responseDataPack) {
49
54
  res = _vtils.DataPacker.packAsRawType(res);
50
55
  }
51
56
 
52
- return res;
57
+ return res == null ? {} : res;
53
58
  };
54
59
 
55
60
  this.handleWs = async (data, ctx) => {
@@ -20,3 +20,5 @@ function makeBaseModel<TModelName extends ModelName>(name: TModelName) {
20
20
 
21
21
  // @index('../.prisma/client/index.d.ts', /(?<=const ModelName:).+?(?=\})/s, /(\S+?):/g, (m, _) => `export const ${_.pascal(m[1])}BaseModel = makeBaseModel('${_.camel(m[1])}')`)
22
22
  // @endindex
23
+
24
+ export * from '@prisma/client'
@@ -34,13 +34,18 @@ export class Handler {
34
34
  }
35
35
  }
36
36
 
37
- let res = await this.options.handle(data, ctx); // 打包返回数据
37
+ let res = await this.options.handle(data, ctx); // 设置响应的 Content-Type 头
38
+
39
+ if (this.options.responseContentType) {
40
+ ctx.setHeader('Content-Type', this.options.responseContentType);
41
+ } // 打包返回数据
42
+
38
43
 
39
44
  if (this.options.responseDataPack) {
40
45
  res = DataPacker.packAsRawType(res);
41
46
  }
42
47
 
43
- return res;
48
+ return res == null ? {} : res;
44
49
  };
45
50
 
46
51
  this.handleWs = async (data, ctx) => {
@@ -2,7 +2,7 @@
2
2
  import { BasePlugin } from '../plugins/base';
3
3
  import { BaseService } from '../services/base';
4
4
  import { yup } from 'vtils/validator';
5
- import type { AsyncOrSync, OneOrMore, RequiredDeep } from 'vtils/types';
5
+ import type { AsyncOrSync, LiteralUnion, OneOrMore, RequiredDeep } from 'vtils/types';
6
6
  import type { DisposeService } from '../services/dispose';
7
7
  import type { Handler } from './handler';
8
8
  import type { IncomingHttpHeaders } from 'http';
@@ -98,6 +98,10 @@ export declare namespace XHandler {
98
98
  * @default false
99
99
  */
100
100
  responseDataPack?: boolean;
101
+ /**
102
+ * 响应的 Content-Type 头
103
+ */
104
+ responseContentType?: LiteralUnion<'text/html', string>;
101
105
  /**
102
106
  * 请求数据验证结构
103
107
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",