anubhavmishra / edge-runtime

A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Supabase Edge Runtime

A web server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.

You can use it to:

  • Locally test and self-host Supabase's Edge Functions (or any Deno Function)
  • As a programmable HTTP Proxy: You can intercept / route HTTP requests

WARNING: Beta Software. There will be breaking changes to APIs / Configuration Options

Architecture

The edge runtime can be divided into two runtimes with different purposes.

  • Main runtime:
    • An instance for the main runtime is responsible for proxying the transactions to the user runtime.
    • The main runtime is meant to be an entry point before running user functions, where you can authentication, etc. before calling the user function.
    • Has no user-facing limits
    • Has access to all environment variables.
  • 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.

How to run locally

To serve all functions in the examples folder on port 9000, you can do this with the example main service provided with this repo

./run.sh start --main-service ./examples/main -p 9000

Test by calling the hello world function

curl --request POST 'http://localhost:9000/hello-world' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "John Doe"
}'

To run with a different entry point, you can pass a different main service like below

./run.sh start --main-service /path/to/main-service-directory -p 9000

using Docker:

docker build -t edge-runtime .
docker run -it --rm -p 9000:9000 -v /path/to/supabase/functions:/usr/services supabase/edge-runtime start --main-service /usr/services

How to run tests

Read about running tests here

How to update to a newer Deno version

Contributions

We welcome contributions to Supabase Edge Runtime!

To get started either open an issue on GitHub or drop us a message on Discord

Edge Runtime follows Supabase's Code of Conduct.

About

A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services.

License:MIT License


Languages

Language:Rust 94.8%Language:TypeScript 4.5%Language:JavaScript 0.5%Language:Dockerfile 0.1%Language:Shell 0.1%