All Projects → second-state → wasmedge-nodejs-starter

second-state / wasmedge-nodejs-starter

Licence: other
A template project to run Rust functions in Node.js through the Second State WebAssembly engine.

Programming Languages

javascript
184084 projects - #8 most used programming language
rust
11053 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to wasmedge-nodejs-starter

ssvm-deno-starter
A template project to run Rust functions in Deno through the Second State WebAssembly engine.
Stars: ✭ 50 (-66.22%)
Mutual labels:  getting-started, webassembly-tutorial, second-state, ssvm, ssvmup, codespaces, vscode-codespaces
rustwasmc
Tool for building Rust functions for Node.js. Combine the performance of Rust, safety and portability of WebAssembly, and ease of use of JavaScript.
Stars: ✭ 97 (-34.46%)
Mutual labels:  node-js, second-state
yaclt
Yet Another Change Log Tool
Stars: ✭ 24 (-83.78%)
Mutual labels:  node-js
live-plugin-manager
Plugin manager and installer for Node.JS
Stars: ✭ 172 (+16.22%)
Mutual labels:  node-js
ifto
A simple debugging module for AWS Lambda (λ) timeout
Stars: ✭ 72 (-51.35%)
Mutual labels:  node-js
Luki
[Deprecated] The official repository for Luki the Discord bot
Stars: ✭ 21 (-85.81%)
Mutual labels:  node-js
pacNEM
pacNEM is a Browser PacMan game with NodeJS, Socket.io, Handlebars and NEM Blockchain
Stars: ✭ 20 (-86.49%)
Mutual labels:  node-js
Nodebestpractices
✅ The Node.js best practices list (December 2021)
Stars: ✭ 72,734 (+49044.59%)
Mutual labels:  node-js
Middleman-NPM
Middleman is an intuitive Express performance monitor for all your middleware 🎉
Stars: ✭ 13 (-91.22%)
Mutual labels:  node-js
Max-Bot
Max Bot is an open-source bot made in node-js with discord-js. It Has Commands from fun to moderator.
Stars: ✭ 27 (-81.76%)
Mutual labels:  node-js
Retrofit2Samples
Retrofit2 Samples 与 Nodejs 服务端接口
Stars: ✭ 17 (-88.51%)
Mutual labels:  node-js
Gyromina
Gyromina, a multipurpose Discord bot with fun + function all in one
Stars: ✭ 97 (-34.46%)
Mutual labels:  node-js
learn-how-to-build-a-mean-stack-application
The goal of this tutorial is to guide you through the coding of a full-stack JavaScript example application project and connecting a backend API to an Angular 5 front-end application employing the MEAN stack.
Stars: ✭ 55 (-62.84%)
Mutual labels:  node-js
HIMS
Hospital Information Management System create using Node Js
Stars: ✭ 41 (-72.3%)
Mutual labels:  node-js
majo.exe
🚀 Discord bot for fun, memes, images, giveaway moderation, anime, NSFW and even more! With over 150 slash commands
Stars: ✭ 188 (+27.03%)
Mutual labels:  node-js
dropbox-fs
📦 Node FS wrapper for Dropbox
Stars: ✭ 35 (-76.35%)
Mutual labels:  node-js
python-wechaty-getting-started
Python Wechaty Starter Project Template that Works Out-of-the-Box
Stars: ✭ 140 (-5.41%)
Mutual labels:  getting-started
win-ca
Get Windows System Root certificates
Stars: ✭ 78 (-47.3%)
Mutual labels:  node-js
ChatBot
A W.I.P All-in-One Discord Bot
Stars: ✭ 32 (-78.38%)
Mutual labels:  node-js
bookshelf
Hanami "Getting Started" project
Stars: ✭ 20 (-86.49%)
Mutual labels:  getting-started

Getting started

Build and test

Fork this project to create your own Rust functions as a web service.

How it works

  • The Rust function source code is in the src/lib.rs file.
  • Use the rustwasmc tool to compile the Rust function into a WebAssembly module in the pkg directory.
  • Optional: Use the node node/app.js command to test the function locally in Node.js.
  • Upload the pkg/*.wasm file to the Second State FaaS service, OR to a Node.js server, to turn it into a web service.

Setup

It is easy to use our appdev Docker image to run the dev environment. You can choose from x86_64 or aarch64 versions of the image. Alternatively, you could also use Github Codespaces to run the following example.

$ docker pull wasmedge/appdev_x86_64
$ docker run -p 3000:3000 --rm -it -v $(pwd):/app wasmedge/appdev_x86_64
(docker) #

Build

Use the rustwasmc command to build the Rust function into a WebAssembly bytecode file.

(docker) # cd /app
(docker) # rustwasmc build

Test and debug

From the first terminal window, start the Node.js application.

(docker) # node node/app.js

From a second terminal window, you can test the local server.

$ curl http://localhost:3000/?name=WasmEdge
hello WasmEdge

Optional: Upload to the FaaS and test

Upload the wasm file in the pkg folder to the FaaS. Double check the .wasm file name before you upload.

(docker) # curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/executables' \
--header 'Content-Type: application/octet-stream' \
--header 'SSVM-Description: say hello' \
--data-binary '@pkg/hello_lib_bg.wasm'

The FaaS returns

{"wasm_id":161,"wasm_sha256":"0xfb413547a8aba56d0349603a7989e269f3846245e51804932b3e02bc0be4b665","usage_key":"00000000-0000-0000-0000-000000000000","admin_key":"00xxxxxx-xxxx-xxxx-xxxx-4adc960fd2b8"}

Make a function call via the web.

(docker) # curl --location --request POST 'https://rpc.ssvm.secondstate.io:8081/api/run/161/say' \
--header 'Content-Type: text/plain' \
--data-raw 'Second State FaaS'
hello Second State FaaS

You can easily incorporate this web service into your HTML web pages. See how

More exercises

Now, you can copy and paste code from this project.

Read more:

Resources

  • The WasmEdge Runtime is a high performance WebAssembly virtual machine designed for edge computing (including Edge Cloud) applications.
  • The rustwasmc is a toolchain for compiling Rust programs into WebAssembly, and then make them accessible from JavaScripts via the WasmEdge Runtime.
  • The Second State FaaS is an open source FaaS engine based on WebAssembly and Node.js.

Brought to you by the Open source dev team at Second State. Follow us on Twitter, Facebook, LinkedIn, YouTube, or Medium

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].