#Choosing the design for my code

5 messages · Page 1 of 1 (latest)

languid surge
#

Hello.

I'm excited to migrate my code to Tauri.
For now it was a SPA served on the web together with a desktop app acting like a proxy for some features.
The context is an internal service tool for field service on industrial machine.

The proxy was used to :

  • remove cors from internal, local rest api server
  • deal with bad tls certificate from Siemens JsonRpc api
  • redirect TCP to a websocket (some embedded soft send theirs diagnostic through raw ASCII over TCP - we used putty to display it).

So far I just embedded the front into Tauri. It was extremely easy and promising.

But of course I still need to rewrite all this "proxy" features within the Tauri app (on top of adding new features like updater, network configurator, auto vpn connection, image manipulation, etc.).

Now my question: what is the most reliable architecture for my code:

  • keep the current one (front end calling every ressources not directly accessible through the proxy - rewritten in rust).
  • create Tauri command for every need of my front end: here I had need at least a way to codegen openapi to rust (I checked, it exist), but then also to codegen the typescript interface to the Tauri command... Seems a lot of work for not much
  • send all http request through the desktop app instead of the WebView, but I'm not sure how to modify the openapi typescript generated files to use the Tauri http plugin. And how to deal with the cors and the bad certificates in the plugin.
  • regarding the TCP redirect part, should I keep the websocket or should I prefer IPC events ? We are talking about max 3 pages of ASCII of 2K per second. It was working smooth with websocket for one or two connection, but I might want to open up to 15 connection to different boards - then I think it would be better to parse in rust and send only the user required data to the front.

Before I rush into one of the solutions and because I'm not a software developer at first, I'd like to know how pro would do.

Thanks.

eternal coral
#

I'd like to know how pro would do.
They'd probably go for the least amount of work lol, so option 1

#

create Tauri command for every need of my front end: here I had need at least a way to codegen openapi to rust (I checked, it exist), but then also to codegen the typescript interface to the Tauri command... Seems a lot of work for not much
agreed

#

send all http request through the desktop app instead of the WebView, but I'm not sure how to modify the openapi typescript generated files to use the Tauri http plugin.
The http plugin's fetch interface should roughly match the native fetch function so overwriting window.fetch may work for you.
And how to deal with the cors and the bad certificates in the plugin.
cors isn't a thing in the plugin. and there's a acceptInvalidCerts setting for the latter.

#

regarding the TCP redirect part, should I keep the websocket or should I prefer IPC events ? We are talking about max 3 pages of ASCII of 2K per second. It was working smooth with websocket for one or two connection, but I might want to open up to 15 connection to different boards - then I think it would be better to parse in rust and send only the user required data to the front.
Web sockets are probably faster than the ipc (at least as fast). So unless you do the last part (optimize what gets send over the ipc) websockets are probably better.