tlsd 2.12.1 → 2.12.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/tlsd.js +25 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlsd",
3
- "version": "2.12.1",
3
+ "version": "2.12.2",
4
4
  "description": "A server for web app prototyping with HTTPS and Websockets",
5
5
  "main": "tlsd.js",
6
6
  "bin": {
package/tlsd.js CHANGED
@@ -82,16 +82,36 @@ function rpc_handler( root, msg, transport, _okay, _fail ) {
82
82
  };
83
83
 
84
84
  try {
85
- const mod = require( root + "/rpc/index.cjs" );
85
+ // try loading explicit common js module
86
+ const path = root + "/rpc/index.cjs";
87
+ V( "path=" + path );
88
+ const mod = require( path );
86
89
  try {
87
90
  mod( msg, okay, ouch, transport );
88
91
  } catch( err ) {
89
- E( (err instanceof Error ) ? err.stack : err );
90
- ouch( "RPC handler exception" );
92
+ E( (err instanceof Error ) ? err.stack : err );
93
+ ouch( "RPC handler exception" );
91
94
  }
95
+
92
96
  } catch( err ) {
93
- E( (err instanceof Error ) ? err.stack : err );
94
- ouch( "Error loading RPC handler" );
97
+
98
+ // try loading it the old way using the dir
99
+ try {
100
+ const path = root + "/rpc";
101
+ V( "path=" + path );
102
+ const mod = require( path );
103
+ try {
104
+ mod( msg, okay, ouch, transport );
105
+ } catch( err ) {
106
+ E( (err instanceof Error ) ? err.stack : err );
107
+ ouch( "RPC handler exception" );
108
+ }
109
+
110
+ } catch( err ) {
111
+ E( (err instanceof Error ) ? err.stack : err );
112
+ ouch( "Error loading RPC handler" );
113
+ }
114
+
95
115
  }
96
116
  };
97
117