node-mole-rpc icon indicating copy to clipboard operation
node-mole-rpc copied to clipboard

protocols that include methods whose name begins with underscore not supported

Open leomoisio opened this issue 4 years ago • 4 comments

Underscore appears to be legal first character for a method name in jsonrpc 2.0 but the implementation won't allow such method to be found - there's an explicit check against it in https://github.com/koorchik/node-mole-rpc/blob/master/MoleServer.js#L54 and this is even documented to be the case.

So currently the library can't be used with a protocol that has such method names in use.

leomoisio avatar Aug 03 '20 13:08 leomoisio

It is done intentionally. A common convention is to start private methods with an underscore. Could you describe your use case where underscore is required? I could add an option to ignore this check

koorchik avatar Aug 05 '20 13:08 koorchik

My use case is to work with a protocol that already has such methods whose names begin with underscore, and I can't change the protocol. I need to be able to receive and respond to such requests.

leomoisio avatar Aug 06 '20 11:08 leomoisio

Yes, it makes sense to add an option like "allowPrivateMethods" or something like that. Is it a real case or a hypothetical situation?

koorchik avatar Aug 06 '20 13:08 koorchik

It's a real case for a proprietary API, it did block me from using the library for this particular purpose.

Would it make sense to allow the exposed server class have a resolver method that gets the name of the jsonrpc method and tells which method to call?

leomoisio avatar Aug 06 '20 17:08 leomoisio