vovk 3.0.0-draft.60 → 3.0.0-draft.61

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.
@@ -4,7 +4,7 @@ exports.StreamJSONResponse = void 0;
4
4
  require("./utils/shim");
5
5
  class StreamJSONResponse extends Response {
6
6
  static defaultHeaders = {
7
- 'content-type': 'application/jsonl',
7
+ 'content-type': 'text/plain; format=jsonlines',
8
8
  };
9
9
  isClosed = false;
10
10
  controller;
@@ -39,12 +39,12 @@ const defaultFetcher = async ({ httpMethod, getEndpoint, validate, defaultHandle
39
39
  throw new HttpException_1.HttpException(types_1.HttpStatus.NULL, e?.message ?? exports.DEFAULT_ERROR_MESSAGE);
40
40
  }
41
41
  const contentType = response.headers.get('content-type');
42
- if (contentType?.includes('application/jsonl')) {
43
- return defaultStreamHandler(response);
44
- }
45
- if (contentType?.includes('application/json')) {
42
+ if (contentType?.startsWith('application/json')) {
46
43
  return defaultHandler(response);
47
44
  }
45
+ if (contentType === 'text/plain; format=jsonlines') {
46
+ return defaultStreamHandler(response);
47
+ }
48
48
  return response;
49
49
  };
50
50
  exports.default = defaultFetcher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "3.0.0-draft.60",
3
+ "version": "3.0.0-draft.61",
4
4
  "main": "dist/index.js",
5
5
  "description": "RESTful RPC for Next.js - Transforms Next.js into a powerful REST API platform with RPC capabilities.",
6
6
  "repository": {
@@ -3,7 +3,7 @@ import './utils/shim';
3
3
 
4
4
  export class StreamJSONResponse<T> extends Response {
5
5
  public static defaultHeaders = {
6
- 'content-type': 'application/jsonl',
6
+ 'content-type': 'text/plain; format=jsonlines',
7
7
  };
8
8
 
9
9
  public isClosed = false;
@@ -45,14 +45,16 @@ const defaultFetcher: VovkClientFetcher<VovkDefaultFetcherOptions> = async (
45
45
 
46
46
  const contentType = response.headers.get('content-type');
47
47
 
48
- if (contentType?.includes('application/jsonl')) {
49
- return defaultStreamHandler(response);
50
- }
48
+
51
49
 
52
- if (contentType?.includes('application/json')) {
50
+ if (contentType?.startsWith('application/json')) {
53
51
  return defaultHandler(response);
54
52
  }
55
53
 
54
+ if (contentType === 'text/plain; format=jsonlines') {
55
+ return defaultStreamHandler(response);
56
+ }
57
+
56
58
  return response;
57
59
  };
58
60