diff --git a/docs/docs/get-started/how-it-works.md b/docs/docs/get-started/how-it-works.md index 2163ab97..1972f766 100644 --- a/docs/docs/get-started/how-it-works.md +++ b/docs/docs/get-started/how-it-works.md @@ -18,12 +18,11 @@ Wasm Workers is built around two main ideas: Based on these two principles, the server performs the following tasks: -* Identify `.wasm` modules in the given folder -* Associate a HTTP route to every module -* Create a Key / Value in-memory store if required -* Initialize the [Wasmtime](https://wasmtime.dev/) runtime -* Compile the different modules and initialize them -* Spin an HTTP server to start serving the requests +* Identify `.wasm` modules and any other supported languages (like `.js` and `.py`) in the given folder. +* Associate a HTTP route to every module. +* Create a Key / Value in-memory store if required. +* Initialize the [Wasmtime](https://wasmtime.dev/) runtime.. +* Start a HTTP server to start serving the requests. ## Convention over configuration @@ -40,4 +39,4 @@ version = "1" namespace = "counter" ``` -These files are only required to enable extra features for your workers. \ No newline at end of file +These files are only required to enable extra features for your workers. diff --git a/docs/docs/get-started/introduction.md b/docs/docs/get-started/introduction.mdx similarity index 75% rename from docs/docs/get-started/introduction.md rename to docs/docs/get-started/introduction.mdx index 4515fc29..0742fcde 100644 --- a/docs/docs/get-started/introduction.md +++ b/docs/docs/get-started/introduction.mdx @@ -2,40 +2,21 @@ sidebar_position: 1 --- +import Diagram from '../../src/pages/diagram.svg'; + # Introduction ## What's Wasm Workers Server? -Wasm Workers Server is a framework that allows you to develop and run serverless applications using a lightweight construct called "workers", explained later in the document. The server itself is implemented as a self-contained binary that routes HTTP requests to a WebAssembly runtime that hosts the workers. It looks for `.wasm` and other compatible modules (like JavaScript files) in the given folder and associate HTTP endpoints based on their path: - -```bash -$ wws --help -Usage: wws [OPTIONS] [PATH] [COMMAND] - -Commands: - runtimes Manage the language runtimes in your project - help Print this message or the help of the given subcommand(s) - -Arguments: - [PATH] Folder to read WebAssembly modules from [default: .] - -Options: - --host Hostname to initiate the server [default: 127.0.0.1] - -p, --port Port to initiate the server [default: 8080] - --prefix Prepend the given path to all URLs [default: ] - -h, --help Print help - -V, --version Print version -``` - -You don't need to configure anything by default. Just drop your workers in a folder and run the project to get an HTTP server and start serving requests 🚀. +Wasm Workers Server is a framework that allows you to develop and run serverless applications using a lightweight construct called "workers", explained later in the document. The server itself is implemented as a self-contained binary that routes HTTP requests to a WebAssembly runtime that hosts the workers. It looks for `.wasm` and other compatible modules (like [JavaScript](../languages/javascript.md) and [Python](../languages//python.md) files) in the given folder and associate HTTP endpoints based on their path: -```bash -$ curl http://localhost:8080/api/hello +

+ +

-Hello Wasm! -``` +You don't need to configure anything by default. Just provide a project location to `wws` and it will identify the workers and start serving requests 🚀. -That's all! Now it's your turn [to download and start using Wasm Workers Server](./quickstart.md). +Now it's your turn [to download and start using Wasm Workers Server](./quickstart.md). ## What's a worker? @@ -57,4 +38,4 @@ Wasm Workers Server is a lightweight implementation of a Worker platform that ai It aims for compatibility and follows an ongoing specification that different companies are working under the name of [WinterCG](https://wintercg.org/faq). This working group aims to create a common API for using Web Platform APIs like workers outside of the browser. -Many of the platforms mentioned earlier follow a similar approach, so any code you write for Wasm Workers Server can be moved to those platforms easily (or the other way around!). Remember that our focus with wws is simplicity and compatibility. Since this is a growing ecosystem, we want you to start quickly and move wherever you need. \ No newline at end of file +Many of the platforms mentioned earlier follow a similar approach, so any code you write for Wasm Workers Server can be moved to those platforms easily (or the other way around!). Remember that our focus with wws is simplicity and compatibility. Since this is a growing ecosystem, we want you to start quickly and move wherever you need. diff --git a/docs/docs/get-started/quickstart.md b/docs/docs/get-started/quickstart.md index 92ee3e12..df5886de 100644 --- a/docs/docs/get-started/quickstart.md +++ b/docs/docs/get-started/quickstart.md @@ -15,7 +15,8 @@ curl -fsSL https://workers.wasmlabs.dev/install | bash Now, you can check the different commands and options: ```bash -wws --help +$ wws --help +A WebAssembly framework to develop and run serverless applications anywhere Usage: wws [OPTIONS] [PATH] [COMMAND] @@ -24,32 +25,38 @@ Commands: help Print this message or the help of the given subcommand(s) Arguments: - [PATH] Folder to read WebAssembly modules from [default: .] + [PATH] Location of the wws project. It could be a local folder or a git repository [default: .] Options: - --host Hostname to initiate the server [default: 127.0.0.1] - -p, --port Port to initiate the server [default: 8080] - --prefix Prepend the given path to all URLs [default: ] - -h, --help Print help information - -V, --version Print version information + --host Hostname to initiate the server [default: 127.0.0.1] + -p, --port Port to initiate the server [default: 8080] + --prefix Prepend the given path to all URLs [default: ] + --ignore Patterns to ignore when looking for worker files [default: ] + -i, --install-runtimes Install missing runtimes automatically + --git-commit Set the commit when using a git repository as project + --git-tag Set the tag when using a git repository as project + --git-branch Set the branch when using a git repository as project + --git-folder Change the directory when using a git repository as project + --enable-panel Enable the administration panel + -h, --help Print help + -V, --version Print version ``` -You can download some of our example `.js` modules: +You can pass a remote location, like a git repository, to `wws`. To try it, let's run one of the `js-basic` example from the Wasm Workers Server repository: ```bash -curl https://raw.githubusercontent.com/vmware-labs/wasm-workers-server/main/examples/js-basic/index.js \ - -o ./index.js +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-basic" ``` -Finally, you can run wws and check the response from the worker: +It automatically clones the git repository and loads the workers from the given folder (`examples/js-basic`): -```bash -wws . - -⚙️ Loading routes from: ./examples -🗺 Detected routes: +```shell +⚙️ Preparing the project from: https://github.com/vmware-labs/wasm-workers-server.git +⚙️ Loading routes from: /tmp/dd21e3cd6d0f515301e1c7070e562af06074d9e8d10566179f97dba47e74cec9/examples/js-basic +⏳ Loading workers from 1 routes... +✅ Workers loaded in 108.82825ms. - http://127.0.0.1:8080/ - => index.js (name: default) + => /tmp/dd21e3cd6d0f515301e1c7070e562af06074d9e8d10566179f97dba47e74cec9/examples/js-basic/index.js 🚀 Start serving requests at http://127.0.0.1:8080 ``` @@ -65,4 +72,4 @@ Now you got the taste of Wasm Workers, it's time to create your first worker: * [Create your first Ruby worker](../languages/ruby.md) * [Create your first Go worker](../languages/go.md) -And if you are curious, here you have a guide about [how it works](./how-it-works.md). \ No newline at end of file +And if you are curious, here you have a guide about [how it works](./how-it-works.md). diff --git a/docs/docs/languages/javascript.md b/docs/docs/languages/javascript.md index 2b71afc5..f72006df 100644 --- a/docs/docs/languages/javascript.md +++ b/docs/docs/languages/javascript.md @@ -6,6 +6,22 @@ sidebar_position: 1 Workers based on JavaScript work out of the box with Wasm Workers Server. The server integrates a JavaScript interpreter compiled into a WebAssembly module. Currently, the interpreter we support is [quickjs](https://bellard.org/quickjs/) and we are working on adding new ones. +## Run a JavaScript example + +1. Download `wws`: + + ```bash + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +2. Run the [js-basic]((https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-basic)) example from the Wasm Workers Server's repository: + + ```bash + wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-basic" + ``` + +3. Access to http://localhost:8080. + ## Your first JavaScript worker JavaScript workers are based on the [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) / [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects from the Web Fetch API. Your worker needs to listen to the `fetch` event, which will include an associated `Request` object. The worker function will receive the request and generate a `Response` object to reply to the request. @@ -186,4 +202,4 @@ If you prefer, you can configure the environment variable value dynamically by f * [Basic](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-basic/) * [JSON](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-json/) * [Redirect](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-redirect/) -* [Tic Tac Toe](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-tictactoe/) \ No newline at end of file +* [Tic Tac Toe](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/js-tictactoe/) diff --git a/docs/docs/languages/python.md b/docs/docs/languages/python.md index f2782d97..08a3ab4f 100644 --- a/docs/docs/languages/python.md +++ b/docs/docs/languages/python.md @@ -6,9 +6,25 @@ sidebar_position: 3 The [Python](https://www.python.org/) interpreter is not embedded in Wasm Workers Server. To create workers based on this language, you first need to install a Python runtime. -Fortunately, we provide precompiled `python.wasm` modules in our [WebAssembly Language Runtimes](https://github.com/vmware-labs/webassembly-language-runtimes/) project, so the installation is simple: +Fortunately, we provide precompiled `python.wasm` modules in our [WebAssembly Language Runtimes](https://github.com/vmware-labs/webassembly-language-runtimes/) project, so the installation is simple. -## Installation +## Run a Python example + +1. Download `wws`: + + ```bash + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +2. Run the [python-basic]((https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/python-basic)) example from the Wasm Workers Server's repository. The `-i` flag will install the Python runtime automatically. + + ```bash + wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/python-basic" + ``` + +3. Access to http://localhost:8080. + +## Python runtime Installation To install the Python Wasm module, run the following command: diff --git a/docs/docs/languages/ruby.md b/docs/docs/languages/ruby.md index 7c70c61b..481f2a1b 100644 --- a/docs/docs/languages/ruby.md +++ b/docs/docs/languages/ruby.md @@ -6,9 +6,25 @@ sidebar_position: 4 The [Ruby](https://www.ruby-lang.org/) interpreter is not embedded in Wasm Workers Server. To create workers based on this language, you first need to install a Ruby runtime. -Fortunately, we provide precompiled `ruby.wasm` modules in our [WebAssembly Language Runtimes](https://github.com/vmware-labs/webassembly-language-runtimes/) project, so the installation is simple: +Fortunately, we provide precompiled `ruby.wasm` modules in our [WebAssembly Language Runtimes](https://github.com/vmware-labs/webassembly-language-runtimes/) project, so the installation is simple. -## Installation +## Run a Ruby example + +1. Download `wws`: + + ```bash + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +2. Run the [ruby-basic](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/ruby-basic) example from the Wasm Workers Server's repository. The `-i` flag will install the Ruby runtime automatically. + + ```bash + wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/ruby-basic" + ``` + +3. Access to http://localhost:8080. + +## Ruby runtime installation To install the Ruby Wasm module, run the following command: @@ -170,4 +186,4 @@ If you prefer, you can configure the environment variable value dynamically by f * [Basic](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/ruby-basic/) * [Key / Value](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/ruby-kv/) -* [Environment variables](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/ruby-envs/) \ No newline at end of file +* [Environment variables](https://github.com/vmware-labs/wasm-workers-server/tree/main/examples/ruby-envs/) diff --git a/examples/Makefile b/examples/Makefile index 6ae334d2..2d3d6bb5 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -15,9 +15,9 @@ rust-params: cargo build --target wasm32-wasi --release && \ mv target/wasm32-wasi/release/rust-params.wasm "./[id].wasm" -pdf-create: - cd pdf-create && \ +rust-pdf-create: + cd rust-pdf-create && \ cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/pdf-create.wasm ./index.wasm + mv target/wasm32-wasi/release/rust-pdf-create.wasm ./index.wasm all: rust-basic rust-kv rust-params diff --git a/examples/README.md b/examples/README.md index 2384583c..bfcfc0c1 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,13 +1,18 @@ # Wasm Workers Server examples -This folder includes different handlers. All of them are based on other projects as we aim to create a server that is compatible with different providers. +This folder includes several workers examples. They are written in different languages and showcases all the features from Wasm Workers Server. -## Build +Every example includes a `README.md` file with all the instructions. -### JavaScript workers +## Documentation -Wasm Workers Server includes a `QuickJS` interpreter. JavaScript workers are automatically compatible and you don't need to compile them to WebAssembly, although they will run in it. +* [Quickstart](https://workers.wasmlabs.dev/docs/get-started/quickstart) +* [Features](https://workers.wasmlabs.dev/docs/category/features) -### Rust workers +### Language resources -For Rust workers, you need to use our `wasm-workers-server-kit` crate. This folder contains several examples of its usage. \ No newline at end of file +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) +* [Rust documentation](https://workers.wasmlabs.dev/docs/languages/rust) +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) +* [Ruby documentation](https://workers.wasmlabs.dev/docs/languages/ruby) +* [Go documentation](https://workers.wasmlabs.dev/docs/languages/go) diff --git a/examples/go-basic/README.md b/examples/go-basic/README.md new file mode 100644 index 00000000..eda97845 --- /dev/null +++ b/examples/go-basic/README.md @@ -0,0 +1,31 @@ +# Go basic example + +Compile a Go worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Go](https://go.dev/) +* [TinyGo](https://tinygo.org/getting-started/install/) + +## Build + +```shell-session +tinygo build -o index.wasm -target wasi main.go +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Go documentation](https://workers.wasmlabs.dev/docs/languages/go) +* [Announcing Go support for Wasm Workers Server](https://wasmlabs.dev/articles/go-support-on-wasm-workers-server/) diff --git a/examples/go-envs/README.md b/examples/go-envs/README.md new file mode 100644 index 00000000..ee34f9c1 --- /dev/null +++ b/examples/go-envs/README.md @@ -0,0 +1,32 @@ +# Go environment variables example + +Compile a Go worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Go](https://go.dev/) +* [TinyGo](https://tinygo.org/getting-started/install/) + +## Build + +```shell-session +tinygo build -o envs.wasm -target wasi envs.go +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Environment variables](https://workers.wasmlabs.dev/docs/features/environment-variables) +* [Go documentation](https://workers.wasmlabs.dev/docs/languages/go) +* [Announcing Go support for Wasm Workers Server](https://wasmlabs.dev/articles/go-support-on-wasm-workers-server/) diff --git a/examples/go-kv/README.md b/examples/go-kv/README.md new file mode 100644 index 00000000..2b7a834b --- /dev/null +++ b/examples/go-kv/README.md @@ -0,0 +1,32 @@ +# Go Key / Value store example + +Compile a Go worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Go](https://go.dev/) +* [TinyGo](https://tinygo.org/getting-started/install/) + +## Build + +```shell-session +tinygo build -o counter.wasm -target wasi counter.go +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Key / Value store](https://workers.wasmlabs.dev/docs/features/key-value) +* [Go documentation](https://workers.wasmlabs.dev/docs/languages/go) +* [Announcing Go support for Wasm Workers Server](https://wasmlabs.dev/articles/go-support-on-wasm-workers-server/) diff --git a/examples/go-params/README.md b/examples/go-params/README.md new file mode 100644 index 00000000..61da4ecf --- /dev/null +++ b/examples/go-params/README.md @@ -0,0 +1,32 @@ +# Go dynamic routes example + +Compile a Go worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Go](https://go.dev/) +* [TinyGo](https://tinygo.org/getting-started/install/) + +## Build + +```shell-session +tinygo build -o [id].wasm -target wasi main.go +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Dynamic routes](https://workers.wasmlabs.dev/docs/features/dynamic-routes) +* [Go documentation](https://workers.wasmlabs.dev/docs/languages/go) +* [Announcing Go support for Wasm Workers Server](https://wasmlabs.dev/articles/go-support-on-wasm-workers-server/) diff --git a/examples/js-async/README.md b/examples/js-async/README.md new file mode 100644 index 00000000..88684e4a --- /dev/null +++ b/examples/js-async/README.md @@ -0,0 +1,21 @@ +# JavaScript async worker example + +Run a JavaScript that uses an async function in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-async" +``` + +## Resources + +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/js-basic/README.md b/examples/js-basic/README.md new file mode 100644 index 00000000..5bd19e22 --- /dev/null +++ b/examples/js-basic/README.md @@ -0,0 +1,21 @@ +# JavaScript basic example + +Run a JavaScript that uses `addEventListener` in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-basic" +``` + +## Resources + +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/js-json/README.md b/examples/js-json/README.md new file mode 100644 index 00000000..c0529325 --- /dev/null +++ b/examples/js-json/README.md @@ -0,0 +1,22 @@ +# JavaScript environment variables example + +Run a JavaScript that returns a JSON output based on an environment variable. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-json" +``` + +## Resources + +* [Environment variables](https://workers.wasmlabs.dev/docs/features/environment-variables) +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/js-params/README.md b/examples/js-params/README.md new file mode 100644 index 00000000..ee8d26a5 --- /dev/null +++ b/examples/js-params/README.md @@ -0,0 +1,22 @@ +# JavaScript dynamic routes example + +Run a JavaScript project that include several dynamic routes. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-params" +``` + +## Resources + +* [Dynamic routes](https://workers.wasmlabs.dev/docs/features/dynamic-routes) +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/js-redirect/README.md b/examples/js-redirect/README.md new file mode 100644 index 00000000..b17e7534 --- /dev/null +++ b/examples/js-redirect/README.md @@ -0,0 +1,21 @@ +# JavaScript redirect example + +Run a JavaScript that redirects users to a different URL via custom HTTP Headers and status. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-redirect" +``` + +## Resources + +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/js-tictactoe/README.md b/examples/js-tictactoe/README.md new file mode 100644 index 00000000..a34e58c3 --- /dev/null +++ b/examples/js-tictactoe/README.md @@ -0,0 +1,22 @@ +# JavaScript Tic Tac Toe example + +A complete Tic Tac Toe example in JavaScript. It uses the K/V store to save the information. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/js-tictactoe" +``` + +## Resources + +* [Key / Value store](https://workers.wasmlabs.dev/docs/features/key-value) +* [JavaScript documentation](https://workers.wasmlabs.dev/docs/languages/javascript) diff --git a/examples/protomaps/README.md b/examples/protomaps/README.md index 9f6ffac8..3d5cb258 100644 --- a/examples/protomaps/README.md +++ b/examples/protomaps/README.md @@ -4,6 +4,14 @@ This example runs an entire Maps Service API based on [Protomaps](https://protom > An alternative to map APIs at 1% the cost, via single static files on your own cloud storage. Deploy datasets like OpenStreetMap for your site in minutes. +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + ## TL;DR Run `make all` @@ -47,4 +55,9 @@ make build-image The example map (`./_maps/map.pmtiles`) was created with the ["Protomaps Small Map"](https://app.protomaps.com/downloads/small_map) tool based on the OpenStreetData data. -OpenStreetMap® is open data, licensed under the Open Data Commons Open Database License (ODbL) by the OpenStreetMap Foundation (OSMF). Read more at https://www.openstreetmap.org/copyright and https://opendatacommons.org/licenses/odbl/1-0/. \ No newline at end of file +OpenStreetMap® is open data, licensed under the Open Data Commons Open Database License (ODbL) by the OpenStreetMap Foundation (OSMF). Read more at https://www.openstreetmap.org/copyright and https://opendatacommons.org/licenses/odbl/1-0/. + +# Resources + +* [Mount folders](https://workers.wasmlabs.dev/docs/features/mount-folders) +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) diff --git a/examples/python-basic/README.md b/examples/python-basic/README.md new file mode 100644 index 00000000..abd9c124 --- /dev/null +++ b/examples/python-basic/README.md @@ -0,0 +1,21 @@ +# Python basic example + +Run a Python worker in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/python-basic" +``` + +## Resources + +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) diff --git a/examples/python-envs/README.md b/examples/python-envs/README.md new file mode 100644 index 00000000..7c1ff8d5 --- /dev/null +++ b/examples/python-envs/README.md @@ -0,0 +1,22 @@ +# Python environment variables example + +Run a Python worker that uses environment variables in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/python-envs" +``` + +## Resources + +* [Environment variables](https://workers.wasmlabs.dev/docs/features/environment-variables) +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) diff --git a/examples/python-kv/README.md b/examples/python-kv/README.md new file mode 100644 index 00000000..6417c0ad --- /dev/null +++ b/examples/python-kv/README.md @@ -0,0 +1,22 @@ +# Python Key / Value store example + +Run a Python worker that uses a Key / Value store in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/python-kv" +``` + +## Resources + +* [Key / Value store](https://workers.wasmlabs.dev/docs/features/key-value) +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) diff --git a/examples/python-mount/README.md b/examples/python-mount/README.md new file mode 100644 index 00000000..057f76c3 --- /dev/null +++ b/examples/python-mount/README.md @@ -0,0 +1,22 @@ +# Python mount folders example + +Run a Python worker that uses data from a mounted folder in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/python-mount" +``` + +## Resources + +* [Mount folders](https://workers.wasmlabs.dev/docs/features/mount-folders) +* [Python documentation](https://workers.wasmlabs.dev/docs/languages/python) diff --git a/examples/ruby-basic/README.md b/examples/ruby-basic/README.md new file mode 100644 index 00000000..5d8f0126 --- /dev/null +++ b/examples/ruby-basic/README.md @@ -0,0 +1,21 @@ +# Ruby basic example + +Run a Ruby worker in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/ruby-basic" +``` + +## Resources + +* [Ruby documentation](https://workers.wasmlabs.dev/docs/languages/ruby) diff --git a/examples/ruby-envs/README.md b/examples/ruby-envs/README.md new file mode 100644 index 00000000..622bc1d9 --- /dev/null +++ b/examples/ruby-envs/README.md @@ -0,0 +1,22 @@ +# Ruby environment variables example + +Run a Ruby worker that uses environment variables in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/ruby-envs" +``` + +## Resources + +* [Environment variables](https://workers.wasmlabs.dev/docs/features/environment-variables) +* [Ruby documentation](https://workers.wasmlabs.dev/docs/languages/ruby) diff --git a/examples/ruby-kv/README.md b/examples/ruby-kv/README.md new file mode 100644 index 00000000..ce89dc50 --- /dev/null +++ b/examples/ruby-kv/README.md @@ -0,0 +1,22 @@ +# Ruby Key / Value store example + +Run a Ruby worker that uses a Key / Value store in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/ruby-kv" +``` + +## Resources + +* [Key / Value store](https://workers.wasmlabs.dev/docs/features/key-value) +* [Ruby documentation](https://workers.wasmlabs.dev/docs/languages/ruby) diff --git a/examples/ruby-mount/README.md b/examples/ruby-mount/README.md new file mode 100644 index 00000000..c50e50dd --- /dev/null +++ b/examples/ruby-mount/README.md @@ -0,0 +1,22 @@ +# Ruby mount folders example + +Run a Ruby worker that uses data from a mounted folder in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +## Run + +```shell-session +wws https://github.com/vmware-labs/wasm-workers-server.git -i --git-folder "examples/ruby-mount" +``` + +## Resources + +* [Mount folders](https://workers.wasmlabs.dev/docs/features/mount-folders) +* [Ruby documentation](https://workers.wasmlabs.dev/docs/languages/ruby) diff --git a/examples/rust-basic/README.md b/examples/rust-basic/README.md new file mode 100644 index 00000000..4e49b903 --- /dev/null +++ b/examples/rust-basic/README.md @@ -0,0 +1,35 @@ +# Rust basic example + +Compile a Rust worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Install Rust with rustup](https://www.rust-lang.org/tools/install) +* Install the `wasm32-wasi` target: + + ```shell-session + rustup target add wasm32-wasi + ``` + +## Build + +```shell-session +cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/rust-basic.wasm ./basic.wasm +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Rust documentation](https://workers.wasmlabs.dev/docs/languages/rust) diff --git a/examples/rust-kv/README.md b/examples/rust-kv/README.md new file mode 100644 index 00000000..306fc760 --- /dev/null +++ b/examples/rust-kv/README.md @@ -0,0 +1,36 @@ +# Rust Key / Value example + +Compile a Rust worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Install Rust with rustup](https://www.rust-lang.org/tools/install) +* Install the `wasm32-wasi` target: + + ```shell-session + rustup target add wasm32-wasi + ``` + +## Build + +```shell-session +cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/rust-kv.wasm ./kv.wasm +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Key / Value store](https://workers.wasmlabs.dev/docs/features/key-value) +* [Rust documentation](https://workers.wasmlabs.dev/docs/languages/rust) diff --git a/examples/rust-params/README.md b/examples/rust-params/README.md new file mode 100644 index 00000000..084d23c9 --- /dev/null +++ b/examples/rust-params/README.md @@ -0,0 +1,36 @@ +# Rust dynamic routes example + +Compile a Rust worker to WebAssembly and run it in Wasm Workers Server. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Install Rust with rustup](https://www.rust-lang.org/tools/install) +* Install the `wasm32-wasi` target: + + ```shell-session + rustup target add wasm32-wasi + ``` + +## Build + +```shell-session +cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/rust-params.wasm ./[id].wasm +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Dynamic routes](https://workers.wasmlabs.dev/docs/features/dynamic-routes) +* [Rust documentation](https://workers.wasmlabs.dev/docs/languages/rust) diff --git a/examples/pdf-create/Cargo.lock b/examples/rust-pdf-create/Cargo.lock similarity index 100% rename from examples/pdf-create/Cargo.lock rename to examples/rust-pdf-create/Cargo.lock diff --git a/examples/pdf-create/Cargo.toml b/examples/rust-pdf-create/Cargo.toml similarity index 74% rename from examples/pdf-create/Cargo.toml rename to examples/rust-pdf-create/Cargo.toml index cf9217ca..34717e53 100644 --- a/examples/pdf-create/Cargo.toml +++ b/examples/rust-pdf-create/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "pdf-create" +name = "rust-pdf-create" version = "0.1.0" edition = "2021" [dependencies] anyhow = "1.0.63" wasm-workers-rs = { path = "../../kits/rust" } -printpdf = "0.5.3" \ No newline at end of file +printpdf = "0.5.3" diff --git a/examples/rust-pdf-create/README.md b/examples/rust-pdf-create/README.md new file mode 100644 index 00000000..a8bcf462 --- /dev/null +++ b/examples/rust-pdf-create/README.md @@ -0,0 +1,35 @@ +# Rust PDF example + +Compile a Rust worker to WebAssembly and run it in Wasm Workers Server. This worker generates a PDF based on the request body. + +## Prerequisites + +* Wasm Workers Server (wws): + + ```shell-session + curl -fsSL https://workers.wasmlabs.dev/install | bash + ``` + +* [Install Rust with rustup](https://www.rust-lang.org/tools/install) +* Install the `wasm32-wasi` target: + + ```shell-session + rustup target add wasm32-wasi + ``` + +## Build + +```shell-session +cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/rust-pdf-create.wasm ./index.wasm +``` + +## Run + +```shell-session +wws . +``` + +## Resources + +* [Rust documentation](https://workers.wasmlabs.dev/docs/languages/rust) diff --git a/examples/pdf-create/src/main.rs b/examples/rust-pdf-create/src/main.rs similarity index 100% rename from examples/pdf-create/src/main.rs rename to examples/rust-pdf-create/src/main.rs