Skip to content

yoshuawuyts/sample-wasi-http-js

 
 

Repository files navigation

Sample: wasi:http in JavaScript

Open in GitHub Codespaces

An example project showing how to build a spec-compliant wasi:http/proxy server for WASI 0.2 written in JavaScript.

Check also the sibling Rust project sample-wasi-http-rust

Routes

The following HTTP routes are available from the component:

/               # Hello world
/sleep          # Sleep for {ms} milliseconds
/echo           # Echo the HTTP body
/echo-headers   # Echo the HTTP headers
/echo-trailers  # Echo the HTTP trailers
/upload         # Echo uploaded blob 

Quick Start

The project uses Wasmtime as its runtime. However, if needed, it can easily be adjusted to use jco instead. For wasmtime installation, simply run:

$ curl https://wasmtime.dev/install.sh -sSf | bash

The quickest way to start is by using just.

$ just serve # to build and serve the wasm component on `localhost:8080`
$ curl 127.0.0.1:8080 # to send requests to component.

Alternatively, run:

$ npm install
$ npm build
$ wasmtime serve -S common dist/server.component.wasm

License

Apache-2.0 with LLVM Exception

About

An example `wasi:http` server component written in JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.6%
  • Just 8.4%