Get started with Rust functions in Node.js app without installing any software
In the previous tutorial, we discussed how to create and access Rust functions in Node.js apps. In this tutorial, I will show you how to experiment with development without installing any developer tools software.
- The Rust files are in the
srcdirectory. You can put high performance workload into Rust functions. The Rust build and dependency configuration is in the
nodedirectory and they can access the Rust functions.
node/app.jsfile contains the application.
Next, create a new codespace. Put your forked repository into the Git Repository field. This step takes a few minutes. But once a codespace is created, subsequent openings only take seconds.
Open the source code files and make changes as you wish!
Click on the Run button on the left panel, and then the Launch Program at the top to build and run the application.
The Terminal window at the bottom shows the build progress. It builds the Rust program, and then launches the Node.js app.
The Debug window shows the Node.js server running and waiting for web requests.
Now, open another terminal window in the IDE via the
Terminal -> New Terminalmenu.
From the terminal window, you can test the local server.
$ curl http://127.0.0.1:3000/?name=SSVM
In fact, you can run any Linux command from VSCode's built-in Terminal. You could run
ssvmup buildto build, and then
node node/app.jsto run the Node.js application. The Node.js application could be a server application as we have shown here, or simply a command line program as many of our later examples.
That's it! VSCode has many useful features such as real time error detection and syntax highlighting as you type code, advanced Github integration, and integrations with many many development tools. Enjoy coding!