+`Supabase.ai` uses [onnxruntime](https://onnxruntime.ai/) as internal model
+execution engine, backend by [ort pyke](https://ort.pyke.io/) rust bindings.
+
Following there's specific documentation for both "lands":
Javascript/Frontend
+
+The **onnxruntime** API is available from `globalThis` and shares similar specs of [onnxruntime-common](https://github.com/microsoft/onnxruntime/tree/main/js/common).
+
+The available items are:
+
+- `Tensor`: represent a basic tensor with specified dimensions and data type. -- "The AI input/output"
+- `InferenceSession`: represent the inner model session. -- "The AI model itself"
+
+### Usage
+
+It can be used from the exported `globalThis[Symbol.for("onnxruntime")]` --
+but manipulating it directly is not trivial, so in the future you may use the [Inference API #501](https://github.com/supabase/edge-runtime/pull/501) for a more user friendly API.
+
+```typescript
+const { InferenceSession, Tensor } = globalThis[Symbol.for("onnxruntime")];
+
+// 'create()' supports an url string buffer or the binary data
+const modelUrlBuffer = new TextEncoder().encode("https://huggingface.co/Supabase/gte-small/resolve/main/onnx/model_quantized.onnx");
+const session = await InferenceSession.create(modelUrlBuffer);
+
+// Example only, in real 'feature-extraction' tensors must be created from the tokenizer step.
+const inputs = {
+ input_ids: new Tensor('float32', [1, 2, 3...], [1, 384]),
+ attention_mask: new Tensor('float32', [...], [1, 384]),
+ token_types_ids: new Tensor('float32', [...], [1, 384])
+};
+
+const { last_hidden_state } = await session.run(inputs);
+console.log(last_hidden_state);
+```
+
+### Third party libs
+
+Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching. For further information pleas check the [PR #436](https://github.com/supabase/edge-runtime/pull/436)
+
+> [!WARNING]
+> At this moment users need to explicit target `device: 'auto'` to enable the platform compatibility.
+
+```typescript
+import { env, pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.0.1';
+
+// Broswer cache is now supported for `onnx` models
+env.useBrowserCache = true;
+env.allowLocalModels = false;
+
+const pipe = await pipeline('feature-extraction', 'supabase/gte-small', { device: 'auto' });
+
+const output = await pipe("This embed will be generated from rust land", {
+ pooling: 'mean',
+ normalize: true
+});
+```
+
From b46df4cea3f0459ee86177fc03995276e312e567 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Wed, 21 May 2025 16:19:12 +0100
Subject: [PATCH 16/27] stamp: self-hosting onnxruntime instructions
---
ext/ai/README.md | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/ext/ai/README.md b/ext/ai/README.md
index dac405e5b..f93915f29 100644
--- a/ext/ai/README.md
+++ b/ext/ai/README.md
@@ -73,6 +73,29 @@ const output = await pipe("This embed will be generated from rust land", {
});
```
+### Self-Hosting
+
+**Caching filepath**:
+The `EXT_AI_CACHE_DIR` environment variable can be use to set a custom cache path
+
+**Memory clean up**:
+For Self-Hosting users an extra method is available for `main/index.ts` scope and should be used to clean up unused sessions, consider adding it into your main entrypoint file:
+
+```typescript
+// cleanup unused sessions every 30s
+setInterval(async () => {
+ try {
+ const cleanupCount = await EdgeRuntime.ai.tryCleanupUnusedSession();
+ if (cleanupCount == 0) {
+ return;
+ }
+ console.log('EdgeRuntime.ai.tryCleanupUnusedSession', cleanupCount);
+ } catch (e) {
+ console.error(e.toString());
+ }
+}, 30 * 1000);
+```
+
From 3a4f8bf87960ac952fd4933849b40b288ba30991 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 23 May 2025 20:46:48 +0100
Subject: [PATCH 17/27] stamp: adding `Session` information
---
ext/ai/README.md | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/ext/ai/README.md b/ext/ai/README.md
index f93915f29..d3e6acf85 100644
--- a/ext/ai/README.md
+++ b/ext/ai/README.md
@@ -16,17 +16,15 @@ features for the `Supabase.ai` namespace.
`Supabase.ai` uses [onnxruntime](https://onnxruntime.ai/) as internal model
execution engine, backend by [ort pyke](https://ort.pyke.io/) rust bindings.
-Following there's specific documentation for both "lands":
-
- Javascript/Frontend
+ Javascript docs
The **onnxruntime** API is available from `globalThis` and shares similar specs of [onnxruntime-common](https://github.com/microsoft/onnxruntime/tree/main/js/common).
The available items are:
-- `Tensor`: represent a basic tensor with specified dimensions and data type. -- "The AI input/output"
-- `InferenceSession`: represent the inner model session. -- "The AI model itself"
+- `Tensor`: Represent a basic tensor with specified dimensions and data type. -- "The AI input/output"
+- `InferenceSession`: Represent the inner model session. -- "The AI model itself"
### Usage
@@ -53,7 +51,7 @@ console.log(last_hidden_state);
### Third party libs
-Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching. For further information pleas check the [PR #436](https://github.com/supabase/edge-runtime/pull/436)
+Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching. For further information please check the [PR #436](https://github.com/supabase/edge-runtime/pull/436)
> [!WARNING]
> At this moment users need to explicit target `device: 'auto'` to enable the platform compatibility.
@@ -98,10 +96,11 @@ setInterval(async () => {
-
- Rust/Backend
-
+## The `Session` class
-onnxruntime:
+Prior versions has [introduced](https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions) the `Session` class as alternative to `transformers.js` for *gte-small* model and then was used to provide a [LLM interface](https://supabase.com/docs/guides/functions/ai-models?queryGroups=platform&platform=ollama#using-large-language-models-llm) for Ollama and some other providers.
-the Session class:
+Since the **Model Execution Engine** was created the `Session` class now can focus on LLM interface while the `Session('gte-small')` is for compatibility purposes only.
+
+> [!WARNING]
+> Docs for Session class will end here - There's a open [PR #539](https://github.com/supabase/edge-runtime/pull/539) that may change a lot of things for it.
From f050201e1d4ddb204495d9db91052d32f2919bc8 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 23 May 2025 21:11:52 +0100
Subject: [PATCH 18/27] stamp: adding useful links to main Readme
---
README.md | 11 +++++++++++
crates/base/README.md | 0
ext/node/README.md | 10 +++++++++-
ext/node/polyfills/README.md | 7 ++++---
4 files changed, 24 insertions(+), 4 deletions(-)
create mode 100644 crates/base/README.md
diff --git a/README.md b/README.md
index 412c0ac73..3c0b9e14c 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,17 @@ The edge runtime can be divided into two runtimes with different purposes.
- Limits are required to be set such as: Memory and Timeouts.
- Has access to environment variables explictly allowed by the main runtime.
+### Edge Runtime in Deep
+
+#### Conceptual
+
+- [EdgeRuntime Base](/crates/base/README.md): Overalls about how EdgeRuntime is based on Deno.
+
+#### Extension Modules
+
+- [AI](/ext/ai/README.md): Implements AI related features.
+- [NodeJs](/ext/node/README.md) & [NodeJs Polyfills](/ext/node/polyfills/README.md): Implements the NodeJs compatibility layer.
+
## Developers
To learn how to build / test Edge Runtime, visit [DEVELOPERS.md](DEVELOPERS.md)
diff --git a/crates/base/README.md b/crates/base/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/ext/node/README.md b/ext/node/README.md
index d154d8cb6..87d08a664 100644
--- a/ext/node/README.md
+++ b/ext/node/README.md
@@ -1,3 +1,11 @@
-# deno_node
+# Supabase Node module
+
+This crate is part of the Supabase Edge Runtime stack and implements NodeJs
+related features.
+
+To see all compatible features, please check the
+[NodeJs Polyfills](/ext/node/polyfills/README.md) section.
+
+## deno_node
`require` and other node related functionality for Deno.
diff --git a/ext/node/polyfills/README.md b/ext/node/polyfills/README.md
index 26527278e..1e6e82bdc 100644
--- a/ext/node/polyfills/README.md
+++ b/ext/node/polyfills/README.md
@@ -1,6 +1,7 @@
-# Deno Node.js compatibility
+# Supabase Node.js compatibility module
-This module is meant to have a compatibility layer for the
+This crate is part of the Supabase Edge Runtime stack and implements a
+compatibility layer for the
[Node.js standard library](https://nodejs.org/docs/latest/api/).
**Warning**: Any function of this module should not be referred anywhere in the
@@ -59,7 +60,7 @@ Deno standard library as it's a compatibility module.
- [x] worker_threads
- [ ] zlib
-* [x] node globals _partly_
+- [x] node globals _partly_
### Deprecated
From 50248184e485762b6b4b1814af8141369e037e9e Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 23 May 2025 21:20:06 +0100
Subject: [PATCH 19/27] stamp: improving
---
ext/ai/README.md | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/ext/ai/README.md b/ext/ai/README.md
index d3e6acf85..aece5d0a4 100644
--- a/ext/ai/README.md
+++ b/ext/ai/README.md
@@ -16,19 +16,17 @@ features for the `Supabase.ai` namespace.
`Supabase.ai` uses [onnxruntime](https://onnxruntime.ai/) as internal model
execution engine, backend by [ort pyke](https://ort.pyke.io/) rust bindings.
-
- Javascript docs
-
The **onnxruntime** API is available from `globalThis` and shares similar specs of [onnxruntime-common](https://github.com/microsoft/onnxruntime/tree/main/js/common).
The available items are:
-- `Tensor`: Represent a basic tensor with specified dimensions and data type. -- "The AI input/output"
-- `InferenceSession`: Represent the inner model session. -- "The AI model itself"
+- `Tensor`: Represent a basic tensor with specified dimensions and data type. - "The AI input/output"
+- `InferenceSession`: Represent the inner model session. - "The AI model itself"
-### Usage
+
+Usage
-It can be used from the exported `globalThis[Symbol.for("onnxruntime")]` --
+It can be used from the exported `globalThis[Symbol.for("onnxruntime")]` -
but manipulating it directly is not trivial, so in the future you may use the [Inference API #501](https://github.com/supabase/edge-runtime/pull/501) for a more user friendly API.
```typescript
@@ -49,6 +47,8 @@ const { last_hidden_state } = await session.run(inputs);
console.log(last_hidden_state);
```
+
+
### Third party libs
Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching. For further information please check the [PR #436](https://github.com/supabase/edge-runtime/pull/436)
@@ -94,8 +94,6 @@ setInterval(async () => {
}, 30 * 1000);
```
-
-
## The `Session` class
Prior versions has [introduced](https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions) the `Session` class as alternative to `transformers.js` for *gte-small* model and then was used to provide a [LLM interface](https://supabase.com/docs/guides/functions/ai-models?queryGroups=platform&platform=ollama#using-large-language-models-llm) for Ollama and some other providers.
From ffc69bd535174789475cd67e976894f657dd4f4f Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 23 May 2025 21:27:09 +0100
Subject: [PATCH 20/27] stamp(ai): adding reference to tests folder
---
ext/ai/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ext/ai/README.md b/ext/ai/README.md
index aece5d0a4..7633f327e 100644
--- a/ext/ai/README.md
+++ b/ext/ai/README.md
@@ -51,7 +51,8 @@ console.log(last_hidden_state);
### Third party libs
-Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching. For further information please check the [PR #436](https://github.com/supabase/edge-runtime/pull/436)
+Originaly this backend was created to implicit integrate with [transformers.js](https://github.com/huggingface/transformers.js/). This way users can still consuming a high-level lib at same time they benefits of all Supabase's Model Execution Engine features, like model optimization and caching.
+For further information please check the [PR #436](https://github.com/supabase/edge-runtime/pull/436) as well the [tests folder](/crates/base/test_cases/ai-ort-rust-backend/transformers-js)
> [!WARNING]
> At this moment users need to explicit target `device: 'auto'` to enable the platform compatibility.
From bdc5d34dcd86714b82c9404c13fb560edbd3b3ab Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Mon, 26 May 2025 11:27:16 +0100
Subject: [PATCH 21/27] stamp: improving edge-runtime diagram
---
README.md | 8 +++++++-
assets/edge-runtime-diagram-dark.svg | 4 ++++
assets/edge-runtime-diagram.svg | 25 ++++---------------------
3 files changed, 15 insertions(+), 22 deletions(-)
create mode 100644 assets/edge-runtime-diagram-dark.svg
diff --git a/README.md b/README.md
index 3c0b9e14c..41a5bec8f 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,13 @@ Options**
## Architecture
-
+
+
+
+
+
+
+
The edge runtime can be divided into two runtimes with different purposes.
diff --git a/assets/edge-runtime-diagram-dark.svg b/assets/edge-runtime-diagram-dark.svg
new file mode 100644
index 000000000..e440ef85c
--- /dev/null
+++ b/assets/edge-runtime-diagram-dark.svg
@@ -0,0 +1,4 @@
+
+
+
\ No newline at end of file
diff --git a/assets/edge-runtime-diagram.svg b/assets/edge-runtime-diagram.svg
index 63cfa5ffe..73a032d70 100644
--- a/assets/edge-runtime-diagram.svg
+++ b/assets/edge-runtime-diagram.svg
@@ -1,21 +1,4 @@
-
+
+
+
\ No newline at end of file
From 85438077d377fbb2eaf92f1b1bbfdebd132e1052 Mon Sep 17 00:00:00 2001
From: Kalleby Santos <105971119+kallebysantos@users.noreply.github.com>
Date: Mon, 26 May 2025 11:28:01 +0100
Subject: [PATCH 22/27] fix: diagram width
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 41a5bec8f..86ea30b97 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ Options**
-
+
From 4fc0a1eeb1ddbb6b49e6351e803f0460de6db470 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Mon, 26 May 2025 11:31:47 +0100
Subject: [PATCH 23/27] stamp: add diagram caption
---
assets/edge-runtime-diagram-dark.svg | 4 ++--
assets/edge-runtime-diagram.svg | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/assets/edge-runtime-diagram-dark.svg b/assets/edge-runtime-diagram-dark.svg
index e440ef85c..f19e8b5d2 100644
--- a/assets/edge-runtime-diagram-dark.svg
+++ b/assets/edge-runtime-diagram-dark.svg
@@ -1,4 +1,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/assets/edge-runtime-diagram.svg b/assets/edge-runtime-diagram.svg
index 73a032d70..bc4036c70 100644
--- a/assets/edge-runtime-diagram.svg
+++ b/assets/edge-runtime-diagram.svg
@@ -1,4 +1,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
From d6725f7cd4b7322900f73224b3648a82c0f6fbe0 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Mon, 18 Aug 2025 12:59:47 +0100
Subject: [PATCH 24/27] stamp: add base runtime diagram
---
README.md | 2 +-
crates/base/README.md | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 86ea30b97..0304d9f56 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ The edge runtime can be divided into two runtimes with different purposes.
- User runtime:
- An instance for the _user runtime_ is responsible for executing users' code.
- Limits are required to be set such as: Memory and Timeouts.
- - Has access to environment variables explictly allowed by the main runtime.
+ - Has access to environment variables explicitly allowed by the main runtime.
### Edge Runtime in Deep
diff --git a/crates/base/README.md b/crates/base/README.md
index e69de29bb..a1374b042 100644
--- a/crates/base/README.md
+++ b/crates/base/README.md
@@ -0,0 +1,14 @@
+# Supabase EdgeRuntime base
+
+This crate is part of the Supabase Edge Runtime stack and implements the runtime
+core features.
+
+## Architecture
+
+
+
+
+
+
+
+
From 4f2ac6b1e0632b35c817fafb3c975d33ba4eb58c Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 12 Sep 2025 16:12:14 +0100
Subject: [PATCH 25/27] feat: add usage section
---
README.md | 4 +++
docs/usage.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+)
create mode 100644 docs/usage.md
diff --git a/README.md b/README.md
index 0304d9f56..33d8aa532 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,10 @@ The edge runtime can be divided into two runtimes with different purposes.
- Limits are required to be set such as: Memory and Timeouts.
- Has access to environment variables explicitly allowed by the main runtime.
+### Usage & Self-Hosting
+
+For completely usage and self-host details, visit [usage.md](/docs/usage.md)
+
### Edge Runtime in Deep
#### Conceptual
diff --git a/docs/usage.md b/docs/usage.md
new file mode 100644
index 000000000..895f39d2a
--- /dev/null
+++ b/docs/usage.md
@@ -0,0 +1,74 @@
+# Usage & Self-Hosting
+
+## The edge-runtime CLI
+
+Edge runtime is based on [Deno](https://deno.land) and try to follows the same
+concepts of it. One of them is the edge-runtime is primary a CLI based app and
+have different commands as well parameters.
+
+The easiest way to use edge-runtime is by running it from docker:
+
+```bash
+docker run --rm -it supabase/edge-runtime:v1.69.9
+```
+
+> The version above may be outdated.
+
+
+ CLI output
+
+```
+A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services
+
+Usage: edge-runtime [OPTIONS] [COMMAND]
+
+Commands:
+start Start the server
+bundle Creates an 'eszip' file that can be executed by the EdgeRuntime. Such file contains all the modules in contained in a single binary.
+unbundle Unbundles an .eszip file into the specified directory
+help Print this message or the help of the given subcommand(s)
+
+Options:
+-v, --verbose Use verbose output
+-q, --quiet Do not print any log messages
+ --log-source Include source file and line in log messages
+-h, --help Print help
+-V, --version Print version
+```
+
+
+
+### `start` command
+
+The start command allows you to run JavaScript/TypeScript code in a similar way of standard Deno.
+But with the difference that it expects a main-service entrypoint with the given format: `path/index.ts`
+
+
+ Example
+
+```ts
+// main.ts
+
+console.log('Hello from Edge Runtime!!');
+```
+
+Running it from docker by using `--main-service` parameter:
+
+```bash
+docker run --rm -it -v $(pwd)/main.ts:/home/deno/main/index.ts supabase/edge-runtime:v1.69.9 start --main-service /home/deno/main
+```
+
+In the command above we did first map our local `main.ts` script to an `index.ts` file located at `/home/deno/main` in the docker volume.
+So that we only need to supply this path as "main-service" entrypoint.
+
+Edge runtime will then run the script and print the following output:
+
+```
+Hello from Edge Runtime!!
+main worker has been destroyed
+```
+
+Notice that a *"main worker has been destroyed"* was printed out.
+It means that our main service worker has nothing more to execute so the process will be finished.
+
+
From eaf2776f0411ff2049e5c56f6711de149839ec24 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Fri, 12 Sep 2025 18:50:00 +0100
Subject: [PATCH 26/27] stamp: improving usage docs - main service VS user
worker
---
docs/usage.md | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/docs/usage.md b/docs/usage.md
index 895f39d2a..9ee7a3754 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -72,3 +72,108 @@ Notice that a *"main worker has been destroyed"* was printed out.
It means that our main service worker has nothing more to execute so the process will be finished.
+
+## Edge functions
+
+In the previous section we discussed in how `edge-runtime` cli can be used to run a JavaScript/TypeScript code.
+
+**But how about serving edge functions?** In order to achieve that we must first understand the edge-runtime execution flow.
+
+
+
+
+
+
+
+
+
+### Main Service
+
+The main service is the initial script supplied on `start` command and it's should acts as root level of edge functions. By intercepting the incomming http request and spawing an **User Worker** to handle it.
+
+All code execution here is more permisse, it means that main scope can access filesystem as well other privilegied APIs - like a `sudo` mode!
+
+> When using Supabase Hosting Platform you don't have access to **Main Service** since its implicit managed by Supabase team.
+
+### User Worker
+
+Here's where your edge functions will really be executed!
+
+The user worker is a more restricted and isolated environment, great to put user-specific code.
+
+> When using `supabase functions deploy`, in a Supabase Hosting Platform, all your function code will be executed inside an **User Worker**.
+
+### Self-Hosting
+
+To self-host edge-functions you should manage the main service as well the user worker spawn logic, like [main.ts template](https://github.com/supabase/supabase/blob/d91ea9d4e24c211f666e6e0ff01d290a9f3831cb/docker/volumes/functions/main/index.ts)
+
+The core idea is to have a root level `Deno.serve()` inside the main service and then foward the request to an user worker.
+
+
+ Example
+
+Creating a edge function to say hello!
+
+```ts
+// functions/hello-world/index.ts
+
+Deno.serve(async (req: Request) => {
+ const { name } = await req.json();
+
+ const message = `Hello ${name} from foo!`;
+
+ return Response.json({ message });
+});
+```
+
+Handling http requests at main service level and passing it to a user worker:
+
+```ts
+// main/index.ts
+
+import { exists } from 'jsr:@std/fs/exists';
+
+Deno.serve(async (req: Request) => {
+ console.log('new request', req.url); // http:localhost:9000/hello-world
+
+ const edgeFunctionName = new URL(req.url).pathname; // "hello-world"
+
+ // path relative to docker volume
+ const edgeFunctionFilepath = `/home/deno/functions/${edgeFunctionName}`;
+
+ // ensuring file exists
+ if (!await exists(edgeFunctionFilepath)) {
+ return new Response(null, { status: 404 });
+ }
+
+ try {
+ // spawning a user worker
+ const worker = await EdgeRuntime.userWorkers.create({
+ servicePath: edgeFunctionFilepath,
+ memoryLimitMb: 150,
+ workerTimeoutMs: 1 * 60 * 1000,
+ });
+
+ // fowarding the request to user worker
+ return await worker.fetch(req);
+ } catch (error) {
+ return Response.json({ error }, { status: 500 });
+ }
+});
+```
+
+Executing with docker
+
+```bash
+docker run --rm -it -p 9000:9000 -v $(pwd):/home/deno supabase/edge-runtime:v1.69.9 start --main-service /home/deno/main
+```
+
+Calling the edge function
+
+```bash
+$ curl localhost:9000/hello-world --data '{"name": "Kalleby Santos"}'
+
+{"message":"Hello Kalleby Santos from foo!"}
+```
+
+
From bef679bc600bec58e3c334b4faf15550848bc417 Mon Sep 17 00:00:00 2001
From: kallebysantos
Date: Wed, 17 Sep 2025 19:34:37 +0100
Subject: [PATCH 27/27] stamp: creating api compatibility table - VALUES NOT
VALIDATED
---
docs/usage.md | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/docs/usage.md b/docs/usage.md
index 9ee7a3754..aad38d922 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -103,6 +103,141 @@ The user worker is a more restricted and isolated environment, great to put user
> When using `supabase functions deploy`, in a Supabase Hosting Platform, all your function code will be executed inside an **User Worker**.
+### API Comparison
+
+
+ Deno APIs
+
+
+
+| API | Main Worker | User Worker |
+|---|---|---|
+| [`cloud`](https://docs.deno.com/api/deno/cloud) | ❌ | ❌ |
+| [`fetch`](https://docs.deno.com/api/deno/fetch) | ✅ | ✅ |
+| [`ffi`](https://docs.deno.com/api/deno/ffi) | ❌ | ❌ |
+| [`file-system`](https://docs.deno.com/api/deno/file-system) | ✅ | ❌ |
+| [`gpu`](https://docs.deno.com/api/deno/gpu) | ❌ | ❌ |
+| [`http-server`](https://docs.deno.com/api/deno/http-server) | ✅ | ✅ |
+| [`io`](https://docs.deno.com/api/deno/io) | ❌ | ❌ |
+| [`jupyter`](https://docs.deno.com/api/deno/jupyter) | ❌ | ❌ |
+| [`linter`](https://docs.deno.com/api/deno/linter) | ❌ | ❌ |
+| [`network`](https://docs.deno.com/api/deno/network) | ✅ | ✅ |
+| [`permissions`](https://docs.deno.com/api/deno/permissions) | ✅ | ✅ |
+| [`runtime`](https://docs.deno.com/api/deno/runtime) | ⚠️ | ⚠️ |
+| [`subprocess`](https://docs.deno.com/api/deno/subprocess) | ❌ | ❌ |
+| [`telemetry`](https://docs.deno.com/api/deno/telemetry) | ✅ | ✅ |
+| [`testing`](https://docs.deno.com/api/deno/testing) | ✅ | ✅ |
+| [`websockets`](https://docs.deno.com/api/deno/websockets) | ✅ | ✅ |
+
+> ❌ Not supported
+> ✅ Supported
+> ⚠️Partial supported
+
+
+
+
+ Web APIs
+
+
+
+| API | Main Worker | User Worker |
+|---|---|---|
+| [`cache`](https://docs.deno.com/api/web/cache) | ❌ | ⚠️ **ai models** only |
+| [`canvas`](https://docs.deno.com/api/web/canvas) | ❌ | ❌ |
+| [`crypto`](https://docs.deno.com/api/web/crypto) | ✅ | ✅ |
+| [`encoding`](https://docs.deno.com/api/web/encoding) | ✅ | ✅ |
+| [`events`](https://docs.deno.com/api/web/events) | ✅ | ✅ |
+| [`events`](https://docs.deno.com/api/web/events) | ✅ | ✅ |
+| [`fetch`](https://docs.deno.com/api/web/fetch) | ✅ | ✅ |
+| [`file`](https://docs.deno.com/api/web/file) | ✅ | ✅ |
+| [`gpu`](https://docs.deno.com/api/web/gpu) | ❌ | ❌ |
+| [`io`](https://docs.deno.com/api/web/io) | ✅ | ✅ |
+| [`io`](https://docs.deno.com/api/web/io) | ✅ | ✅ |
+| [`intl`](https://docs.deno.com/api/web/intl) | ✅ | ✅ |
+| [`messaging`](https://docs.deno.com/api/web/messaging) | ✅ | ✅ |
+| [`performance`](https://docs.deno.com/api/web/performance) | ✅ | ✅ |
+| [`platform`](https://docs.deno.com/api/web/platform) | ❌ | ❌ |
+| [`storage`](https://docs.deno.com/api/web/storage) | ❌ | ❌ |
+| [`streams`](https://docs.deno.com/api/web/streams) | ✅ | ✅ |
+| [`temporal`](https://docs.deno.com/api/web/temporal) | ✅ | ✅ |
+| [`url`](https://docs.deno.com/api/web/url) | ✅ | ✅ |
+| [`wasm`](https://docs.deno.com/api/web/wasm) | ✅ | ✅ |
+| [`websockets`](https://docs.deno.com/api/web/websockets) | ✅ | ✅ |
+| [`workers`](https://docs.deno.com/api/web/storage) | ❌ | ❌ |
+
+> ❌ Not supported
+> ✅ Supported
+> ⚠️Partial supported
+
+
+
+
+ Node APIs
+
+
+
+| API | Main Worker | User Worker |
+|---|---|---|
+| [`assert`](https://docs.deno.com/api/node/assert) | ✅ | ✅ |
+| [`assert/strict`](https://docs.deno.com/api/node/assert/~/assert.strict) | ✅ | ✅ |
+| [`assync_hooks`](https://docs.deno.com/api/node/assync_hooks) | ✅ | ✅ |
+| [`buffer`](https://docs.deno.com/api/node/buffer) | ✅ | ✅ |
+| [`child_process`](https://docs.deno.com/api/node/child_process) | ❌ | ❌ |
+| [`cluster`](https://docs.deno.com/api/node/cluster) | ❌ | ❌ |
+| [`console`](https://docs.deno.com/api/node/console) | ⚠️all outputs are trimmed out | ⚠️ same as *Main Worker* |
+| [`crypto`](https://docs.deno.com/api/node/crypto) | ✅ | ✅ |
+| [`dgram`](https://docs.deno.com/api/node/dgram) | ✅ | ✅ |
+| [`diagnostics_channel`](https://docs.deno.com/api/node/diagnostics_channel) | ❌ | ❌ |
+| [`dns`](https://docs.deno.com/api/node/dns) | ✅ | ✅ |
+| [`dns/promisses`](https://docs.deno.com/api/node/dns/promisses) | ✅ | ✅ |
+| [`domain`](https://docs.deno.com/api/node/domain) | ✅ | ✅ |
+| [`events`](https://docs.deno.com/api/node/events) | ✅ | ✅ |
+| [`fs`](https://docs.deno.com/api/node/fs) | ✅ | ❌ |
+| [`fs/promisses`](https://docs.deno.com/api/node/fs/promisses) | ✅ | ❌ |
+| [`http`](https://docs.deno.com/api/node/http) | ✅ | ✅ |
+| [`http2`](https://docs.deno.com/api/node/http2) | ✅ | ✅ |
+| [`https`](https://docs.deno.com/api/node/https) | ✅ | ✅ |
+| [`inspector`](https://docs.deno.com/api/node/inspector) | ✅ | ✅ |
+| [`inspector/promisses`](https://docs.deno.com/api/node/inspector/promisses) | ✅ | ✅ |
+| [`module`](https://docs.deno.com/api/node/module) | ✅ | ✅ |
+| [`net`](https://docs.deno.com/api/node/net) | ✅ | ✅ |
+| [`os`](https://docs.deno.com/api/node/os) | ✅ | ✅ |
+| [`path`](https://docs.deno.com/api/node/path) | ✅ | ✅ |
+| [`perf_hooks`](https://docs.deno.com/api/node/perf_hooks) | ✅ | ✅ |
+| [`process`](https://docs.deno.com/api/node/process) | ✅ | ✅ |
+| [`querystring`](https://docs.deno.com/api/node/querystring) | ✅ | ✅ |
+| [`readline`](https://docs.deno.com/api/node/readline) | ❌ | ❌ |
+| [`readline/promisses`](https://docs.deno.com/api/node/readline/promisses) | ❌ | ❌ |
+| [`repl`](https://docs.deno.com/api/node/repl) | ❌ | ❌ |
+| [`sea`](https://docs.deno.com/api/node/sea) | ❌ | ❌ |
+| [`sqlite`](https://docs.deno.com/api/node/sqlite) | ❌ | ❌ |
+| [`stream`](https://docs.deno.com/api/node/stream) | ✅ | ✅ |
+| [`stream/consumers`](https://docs.deno.com/api/node/stream/consumers) | ✅ | ✅ |
+| [`stream/promisses`](https://docs.deno.com/api/node/stream/promisses) | ✅ | ✅ |
+| [`stream/web`](https://docs.deno.com/api/node/stream/web) | ✅ | ✅ |
+| [`string_decoder`](https://docs.deno.com/api/node/string_decoder) | ✅ | ✅ |
+| [`test`](https://docs.deno.com/api/node/test) | ✅ | ✅ |
+| [`test/reporters`](https://docs.deno.com/api/node/test/reporters) | ✅ | ✅ |
+| [`timers`](https://docs.deno.com/api/node/timers) | ✅ | ✅ |
+| [`timers/promisses`](https://docs.deno.com/api/node/timers/promisses) | ✅ | ✅ |
+| [`tls`](https://docs.deno.com/api/node/tls) | ✅ | ✅ |
+| [`trace_events`](https://docs.deno.com/api/node/trace_events) | ✅ | ✅ |
+| [`tty`](https://docs.deno.com/api/node/tty) | ❌ | ❌ |
+| [`url`](https://docs.deno.com/api/node/url) | ✅ | ✅ |
+| [`util`](https://docs.deno.com/api/node/util) | ✅ | ✅ |
+| [`util/types`](https://docs.deno.com/api/node/util/types) | ✅ | ✅ |
+| [`v8`](https://docs.deno.com/api/node/v8) | ❌ | ❌ |
+| [`vm`](https://docs.deno.com/api/node/vm) | ❌ | ❌ |
+| [`wasi`](https://docs.deno.com/api/node/wasi) | ✅ | ✅ |
+| [`worker_threads`](https://docs.deno.com/api/node/worker_threads) | ✅ | ✅ |
+| [`zlib`](https://docs.deno.com/api/node/zlib) | ✅ | ✅ |
+
+> ❌ Not supported
+> ✅ Supported
+> ⚠️Partial supported
+
+
+
### Self-Hosting
To self-host edge-functions you should manage the main service as well the user worker spawn logic, like [main.ts template](https://github.com/supabase/supabase/blob/d91ea9d4e24c211f666e6e0ff01d290a9f3831cb/docker/volumes/functions/main/index.ts)