rpc-express-toolkit 4.3.2 → 4.3.4

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/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![npm downloads](https://img.shields.io/npm/dm/rpc-express-toolkit.svg)](https://www.npmjs.com/package/rpc-express-toolkit)
8
8
  [![node](https://img.shields.io/node/v/rpc-express-toolkit.svg)](https://www.npmjs.com/package/rpc-express-toolkit)
9
9
 
10
- Enterprise-ready JSON-RPC 2.0 toolkit for Express.js with simplified APIs, middleware, schema validation, batch support, and optional safe type disambiguation.
10
+ JSON-RPC 2.0 toolkit for Express.js with simplified APIs, middleware, schema validation, batch support, and optional Safe Mode type preservation.
11
11
 
12
12
  ## Quick Start
13
13
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rpc-express-toolkit",
3
- "version": "4.3.2",
4
- "description": "Enterprise-ready JSON-RPC 2.0 toolkit for Express.js with simplified APIs, structured logging, middleware system, schema validation, comprehensive BigInt/Date support. JSON middleware validation and explicit configuration.",
3
+ "version": "4.3.4",
4
+ "description": "JSON-RPC 2.0 toolkit for Express.js with simplified APIs, structured logging, middleware, schema validation, batch support, and optional Safe Mode.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
7
7
  "exports": {
@@ -52,7 +52,6 @@
52
52
  "ajv",
53
53
  "bigint",
54
54
  "date",
55
- "enterprise",
56
55
  "nodejs",
57
56
  "node",
58
57
  "browser",
package/src/batch.js CHANGED
@@ -9,6 +9,14 @@ class BatchHandler {
9
9
  this.endpoint = endpoint;
10
10
  }
11
11
 
12
+ serializeErrorData(error, batchIndex) {
13
+ const errorWithBatchIndex = addBatchIndex(error, batchIndex);
14
+ if (!hasOwn(errorWithBatchIndex, 'data')) {
15
+ return undefined;
16
+ }
17
+ return this.endpoint.serializeBigIntsAndDates(errorWithBatchIndex.data);
18
+ }
19
+
12
20
  /**
13
21
  * Check if request is a batch request
14
22
  * @param {any} body
@@ -70,13 +78,14 @@ class BatchHandler {
70
78
  try {
71
79
  return await this.processSingleRequest(request, req, context, index);
72
80
  } catch (error) {
81
+ const errorData = this.serializeErrorData(error, index);
73
82
  return {
74
83
  jsonrpc: '2.0',
75
84
  id: request && hasOwn(request, 'id') ? request.id : null,
76
85
  error: {
77
86
  code: error.code || -32603,
78
87
  message: error.message || 'Internal error',
79
- data: addBatchIndex(error, index).data,
88
+ ...(errorData !== undefined && { data: errorData }),
80
89
  },
81
90
  };
82
91
  }
@@ -269,13 +278,15 @@ class BatchHandler {
269
278
  return null;
270
279
  }
271
280
 
281
+ const errorData = this.serializeErrorData(error, batchIndex);
282
+
272
283
  return {
273
284
  jsonrpc: '2.0',
274
285
  id,
275
286
  error: {
276
287
  code: error.code || -32603,
277
288
  message: error.message || 'Internal error',
278
- data: addBatchIndex(error, batchIndex).data,
289
+ ...(errorData !== undefined && { data: errorData }),
279
290
  },
280
291
  };
281
292
  }
package/src/index.js CHANGED
@@ -675,12 +675,17 @@ class RpcEndpoint {
675
675
  return null;
676
676
  }
677
677
 
678
+ const errorData =
679
+ hasOwn(err, 'data') && err.data !== undefined
680
+ ? this.serializeBigIntsAndDates(err.data)
681
+ : undefined;
682
+
678
683
  this.reply(res, {
679
684
  id,
680
685
  error: {
681
686
  code: err.code || -32603,
682
687
  message: err.message || `Internal error`,
683
- ...(err.data && { data: err.data }),
688
+ ...(errorData !== undefined && { data: errorData }),
684
689
  error: serializeError(err, true),
685
690
  },
686
691
  });