rpc-express-toolkit 2.3.2 → 2.3.3

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.
@@ -1,5 +1,11 @@
1
1
  /**
2
- * Example demonstrating how to use RpcClient with self-signed certificates
2
+ * Example demonstratin // Example 3: Best practices
3
+ console.log('3. Best Practices:');
4
+ console.log(' ✓ Always use SSL validation in production');
5
+ console.log(' ✓ Disable validation only for development with self-signed certificates');
6
+ console.log(' ✓ Use environment variables to control SSL behavior');
7
+ console.log(' ✓ Never commit process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" to production');
8
+ console.log(' ✓ Consider using valid development certificates instead of disabling validation\n');o use RpcClient with self-signed certificates
3
9
  * in development environments.
4
10
  *
5
11
  * WARNING: Only use rejectUnauthorized: false in development!
@@ -20,11 +26,11 @@ async function demonstrateSSLOptions() {
20
26
 
21
27
 
22
28
 
23
- // Example 2: Development client per self-signed certificates (bypassa TUTTA la validazione SSL)
29
+ // Example 2: Development client for self-signed certificates (bypasses ALL SSL validation)
24
30
  console.log('2. Development Client (bypasses SSL validation):');
25
- console.log(' ⚠️ Per bypassare la validazione SSL in Node.js, imposta PRIMA di avviare il client:');
31
+ console.log(' ⚠️ To bypass SSL validation in Node.js, set BEFORE starting the client:');
26
32
  console.log(' process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";');
27
- console.log(' ✓ Tutte le richieste accetteranno certificati self-signed (solo per sviluppo!)\n');
33
+ console.log(' ✓ All requests will accept self-signed certificates (development only!)\n');
28
34
 
29
35
  // Example 3: Best practice
30
36
  console.log('3. Best Practices:');
@@ -41,9 +47,9 @@ async function demonstrateSSLOptions() {
41
47
  const environmentClient = new RpcClient(baseUrl, {
42
48
  'Authorization': `Bearer ${process.env.API_TOKEN || 'default-token'}`,
43
49
  'X-Environment': process.env.NODE_ENV || 'development'
44
- }, isDevelopment ? { ca } : {});
50
+ });
45
51
  console.log(` ✓ Created client for ${isDevelopment ? 'development' : 'production'} environment`);
46
- console.log(` ✓ SSL validation: ${isDevelopment ? 'custom CA (dev only)' : 'enabled (secure)'}\n`);
52
+ console.log(` ✓ SSL validation: ${isDevelopment ? 'controlled by NODE_TLS_REJECT_UNAUTHORIZED' : 'enabled (secure)'}\n`);
47
53
 
48
54
  // Example usage (commented out since we don't have a real server)
49
55
  /*
@@ -56,7 +62,7 @@ async function demonstrateSSLOptions() {
56
62
  }
57
63
  */
58
64
 
59
- console.log('4. Best Practices:');
65
+ console.log('5. Best Practices Summary:');
60
66
  console.log(' ✓ Always use strict SSL validation in production');
61
67
  console.log(' ✓ Only disable SSL validation for development with self-signed certificates');
62
68
  console.log(' ✓ Use environment variables to control SSL behavior');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rpc-express-toolkit",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
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. Advanced SSL options removed, see README.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
package/src/logger.js CHANGED
@@ -100,7 +100,7 @@ class Logger {
100
100
  id,
101
101
  duration: `${duration}ms`,
102
102
  resultType: typeof result,
103
- resultSize: JSON.stringify(result).length
103
+ resultSize: result ? JSON.stringify(result).length : 0
104
104
  });
105
105
  }
106
106