Fable.Remoting icon indicating copy to clipboard operation
Fable.Remoting copied to clipboard

Add Fable.Remoting.NodeClient

Open sergey-tihon opened this issue 3 years ago • 9 comments

Would be nice to have client library for Fable.Remoting that work in Node.js.

One of use cases is the communication with API from vscode extension written with Fable and hosted in a Node.js process in VS Code.

If/when someone decide to contribute client library for Node.js would be nice to have approved transport library.

What can be used instead of XMLHttpRequest for HTTP calls to be merged in this repo?

Should be one of low-lever fable-node modules (like HTTPS for example) or it can be some popular and lightweight http library like got (that is used in REST Client for example.

sergey-tihon avatar Mar 12 '21 07:03 sergey-tihon

Hello, I think one of most popular http library is axios the minified version of the library is 15kb.

MangelMaxime avatar Mar 12 '21 09:03 MangelMaxime

Hi @sergey-tihon I always wanted a reason to have this implemented, now there is one 😄 as for the underlying HTTP client, the priority goes to the built-in client so that we have the least amount of dependencies unless other 3rd-party libraries make our lives easier.

I can't promise a timeline for this but I do want to have it at some point as part of the stack. PRs are always welcome of course 💯

Zaid-Ajaj avatar Mar 12 '21 09:03 Zaid-Ajaj

@MangelMaxime axios looks interesting, because it works inside nodejs process and in the browser.

@Zaid-Ajaj is it an option to port fable client on top of axios? Or 15kb is a large footprint and you prefer to have separate package for nodejs?

sergey-tihon avatar Mar 12 '21 11:03 sergey-tihon

15kb is a large footprint

The size is not so much the problem here but the fact that users have to remember to install another package in order to use Fable.Remoting.Client which I would rather avoid.

Zaid-Ajaj avatar Mar 12 '21 11:03 Zaid-Ajaj

For my use case I implemented API client for Node.js manually https://github.com/sergey-tihon/vscode-openxml-explorer/blob/main/src/extension/Remoting.fs

on top of Fable.Axios updated to Fable 3 https://github.com/sergey-tihon/vscode-openxml-explorer/blob/main/src/extension/Fable.Axios.fs

and opened issues to update Fable.Axios NuGet package.

sergey-tihon avatar Apr 04 '21 12:04 sergey-tihon

if that works for you then all good but just keep in mind that writing axios.post<Document> won't perform proper deserialization and is just saying "please treat this as if it was a Document" so if you have complex fields in your Document type such as unions or maps, they might not really work

Zaid-Ajaj avatar Apr 04 '21 20:04 Zaid-Ajaj

ok, thank you, I all take a look at proper deserialization (when it breaks 😉 )

sergey-tihon avatar Apr 04 '21 20:04 sergey-tihon

Fable.Remoting.Client uses Fable.SimpleJson for JSON handling and deserialization and it should on nodejs without any dependency

Zaid-Ajaj avatar Apr 04 '21 20:04 Zaid-Ajaj

+1 for this. I am writing a service that needs to use a nodejs library, so I'm doing this with fable and the api is using fable remoting, so I would love to have a fable remoting nodejs library.

Darkle avatar Jul 21 '23 04:07 Darkle