Use Case: Toast #57
Unanswered
ChristopherBiscardi
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hiya!
I had a chat with @MylesBorins and said I would drop my use cases here so that they could hopefully help/inform future APIs and such.
tldr; I built a project called Toast that is a Rust-implementation of jamstack metaframework aimed at JS devs.
The idea behind Toast is that the build infrastructure is built in Rust but users from JS-land can write sites as they normally would with CRA/Gatsby/Next etc without even being aware that the infrastructure is written in Rust. Overall this works today by taking advantage of unix domain sockets to communicate between node and Rust.
There are two main places Toast communicates with Rust that would be awesome to replace with JSTime.
data fetching
The data fetching needs to happen in JS-land because the way people fetch data for jamstack/static sites leans on the fact that most headless CMSs have JS SDKs (as well as postgres, dynamo, etc). The same can not be said for Rust SDKs (of which there are approximately none, from what I can tell). So Toast needs to let users fetch data from wherever and does so by providing some helper functions that call across the unix socket for page creation from the data and such (APIs mentioned here subject to change, but idea remains).
createPage
in the following example is a framework-provided function that make unix socket requests under the hood (users don't need to know that though, they see a promise interface).rendering html
At the other end of the rust process, Toast needs to (basically) call
renderToString
. Today that's a preact function and people use all sorts of other components, local and third party, so we need a JS env to run it in that adheres to an esm import pattern. Triggering renders and such happens over sockets, again.There may be other places a JS runtime is useful, such as letting people patch into the Rust version of SWC with JS-written plugins, but these are not implemented and such.
Beta Was this translation helpful? Give feedback.
All reactions