node-mole-rpc
node-mole-rpc copied to clipboard
protocols that include methods whose name begins with underscore not supported
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.
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
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.
Yes, it makes sense to add an option like "allowPrivateMethods" or something like that. Is it a real case or a hypothetical situation?
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?