Skip to content

Commit a006cea

Browse files
authored
Merge pull request #39 from supabase/readme-chores
Update README & other chores
2 parents 0474632 + 39c739f commit a006cea

File tree

21 files changed

+49
-78
lines changed

21 files changed

+49
-78
lines changed

README.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Edge Runtime
1+
# Supabase Edge Runtime
22

33
A web server based on [Deno](https://deno.land) runtime, capable of running JavaScript, TypeScript, and WASM services.
44

5-
### Why are we building this?
5+
You can use it to:
66

7-
The primary goal of this project is to have a runtime environment that can simulate the capabilities and limitations of [Deno Deploy](https://deno.com/deploy).
7+
* Locally test and self-host Supabase's Edge Functions (or any Deno Edge Function)
8+
* As a programmable HTTP Proxy: You can intercept / route HTTP requests
89

9-
This enables Supabase users to test their Edge Functions locally while simulating the behavior at the edge (eg: runtime APIs like File I/O not available, memory and CPU time enforced).
10-
Also, this enables portability of edge functions to those users who want to self-host them outside of Deno Deploy.
10+
** WARNING: Beta Software. There will be breaking changes to APIs / Configuration Options **
1111

1212
## How to run locally
1313

@@ -22,24 +22,6 @@ docker build -t edge-runtime .
2222
docker run -it --rm -p 9000:9000 -v /path/to/supabase/functions:/usr/services supabase/edge-runtime start --main-service /usr/services
2323
```
2424

25-
## TODO
26-
27-
* Expose Deno.errors
28-
* Performance.now() precision tuning
29-
* Disable SharedArrayBuffers
30-
* better error messages for incorrect module loading paths
31-
* better error messages for invalid import map paths
32-
* Support snapshotting the runtime
33-
* Support for private modules (DENO_AUTH_TOKENS)
34-
* HTTP/2 support (need the host to support SSL)
35-
* Add tests
36-
* Add a benchmarking suite
37-
38-
## How to update to a Deno version
39-
40-
* Select the Deno version to upgrade and visit its tag on GitHub (eg: https://github.com/denoland/deno/blob/v1.30.3/Cargo.toml)
41-
* Open the `Cargo.toml` at the root of of this repo and modify all `deno_*` modules to match to the selected tag of Deno.
42-
4325
## How to run tests
4426

4527
make sure the docker daemon is running and create a docker image:
@@ -60,3 +42,16 @@ run tests:
6042
```bash
6143
npm run test
6244
```
45+
46+
## How to update to a newer Deno version
47+
48+
* Select the Deno version to upgrade and visit its tag on GitHub (eg: https://github.com/denoland/deno/blob/v1.30.3/Cargo.toml)
49+
* Open the `Cargo.toml` at the root of of this repo and modify all `deno_*` modules to match to the selected tag of Deno.
50+
51+
## Contributions
52+
53+
We welcome contributions to Supabase Edge Runtime!
54+
55+
To get started either open an issue on [GitHub](https://github.com/supabase/edge-runtime/issues) or drop us a message on [Discord](https://discord.com/invite/R7bSpeBSJE)
56+
57+
Edge Runtime follows Supabase's [Code of Conduct](https://github.com/supabase/.github/blob/main/CODE_OF_CONDUCT.md).

crates/base/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
name = "base"
33
version = "0.1.0"
44
edition = "2021"
5-
build = "build.rs"
65

76
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
87

crates/base/build.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

crates/base/src/js_worker.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::utils::units::{bytes_to_display, human_elapsed, mib_to_bytes};
22

3-
use anyhow::{anyhow, bail, Error};
4-
use deno_core::located_script_name;
3+
use anyhow::{bail, Error};
54
use deno_core::url::Url;
65
use deno_core::JsRuntime;
76
use deno_core::ModuleSpecifier;

crates/base/src/js_worker/module_loader.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{anyhow, bail, Error};
1+
use anyhow::{bail, Error};
22
use deno_ast::EmitOptions;
33
use deno_ast::MediaType;
44
use deno_core::error::AnyError;
@@ -10,8 +10,6 @@ use deno_core::ModuleSpecifier;
1010
use deno_core::ModuleType;
1111
use deno_core::ResolutionKind;
1212
use import_map::ImportMap;
13-
use module_fetcher::cache;
14-
use module_fetcher::cache::cache_db::CacheDB;
1513
use module_fetcher::cache::{
1614
caches, DenoDir, EmitCache, FastInsecureHasher, HttpCache, ParsedSourceCache,
1715
};

crates/base/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::worker_ctx::{WorkerContext, WorkerPool};
22
use anyhow::Error;
33
use hyper::{server::conn::Http, service::Service, Body, Request, Response};
4-
use log::{debug, error, info};
4+
use log::{error, info};
55
use std::future::Future;
66
use std::net::IpAddr;
77
use std::net::Ipv4Addr;

crates/base/src/worker_ctx.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ use crate::js_worker::{MainWorker, UserWorker};
22

33
use anyhow::{bail, Error};
44
use hyper::{Body, Request, Response};
5-
use log::{debug, error};
5+
use log::error;
66
use sb_worker_context::essentials::{CreateUserWorkerResult, UserWorkerMsgs, UserWorkerOptions};
77
use std::collections::HashMap;
88
use std::path::Path;
99
use std::path::PathBuf;
1010
use std::sync::Arc;
1111
use std::thread;
1212
use tokio::net::UnixStream;
13-
use tokio::sync::oneshot::Receiver;
1413
use tokio::sync::RwLock;
1514
use tokio::sync::{mpsc, oneshot};
1615
use uuid::Uuid;
@@ -34,8 +33,8 @@ impl WorkerContext {
3433
let import_map_path = options.import_map_path;
3534
let user_worker_msgs_tx = options.user_worker_msgs_tx;
3635

37-
if (!service_path.exists()) {
38-
return bail!("main function does not exist {:?}", &service_path);
36+
if !service_path.exists() {
37+
bail!("main function does not exist {:?}", &service_path)
3938
}
4039

4140
// create a unix socket pair
@@ -90,8 +89,8 @@ impl WorkerContext {
9089
let import_map_path = options.import_map_path;
9190
let env_vars = options.env_vars;
9291

93-
if (!service_path.exists()) {
94-
return bail!("user function does not exist {:?}", &service_path);
92+
if !service_path.exists() {
93+
bail!("user function does not exist {:?}", &service_path)
9594
}
9695

9796
// create a unix socket pair
@@ -197,7 +196,7 @@ impl WorkerPool {
197196
let mut worker = worker.write().await;
198197
// TODO: Json format
199198
// TODO: Ability to attach hook
200-
let res = worker.send_request(req).await.unwrap_or_else(|e| Response::builder().status(408).body(Body::from(deno_core::serde_json::json!({
199+
let res = worker.send_request(req).await.unwrap_or_else(|_e| Response::builder().status(408).body(Body::from(deno_core::serde_json::json!({
201200
"msg": "Request could not be processed by the server because it timed out or an error was thrown."
202201
}).to_string())).unwrap());
203202

crates/cli/src/main.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod logger;
33
use anyhow::Error;
44
use base::commands::start_server;
55
use clap::builder::FalseyValueParser;
6-
use clap::{arg, value_parser, ArgAction, ArgMatches, Command};
6+
use clap::{arg, value_parser, ArgAction, Command};
77
fn cli() -> Command {
88
Command::new("edge-runtime")
99
.about("A server based on Deno runtime, capable of running JavaScript, TypeScript, and WASM services")
@@ -36,15 +36,15 @@ fn cli() -> Command {
3636
)
3737
}
3838

39-
async fn exit_with_code(result: Result<(), Error>) {
40-
match result {
41-
Ok(()) => std::process::exit(0),
42-
Err(error) => {
43-
eprintln!("{:?}", error);
44-
std::process::exit(1)
45-
}
46-
}
47-
}
39+
//async fn exit_with_code(result: Result<(), Error>) {
40+
// match result {
41+
// Ok(()) => std::process::exit(0),
42+
// Err(error) => {
43+
// eprintln!("{:?}", error);
44+
// std::process::exit(1)
45+
// }
46+
// }
47+
//}
4848

4949
fn main() -> Result<(), anyhow::Error> {
5050
let runtime = tokio::runtime::Builder::new_current_thread()

crates/module_fetcher/src/args/config_file.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use deno_core::serde_json::json;
1717
use deno_core::serde_json::Value;
1818
use deno_core::ModuleSpecifier;
1919
use indexmap::IndexMap;
20-
use std::borrow::Cow;
2120
use std::collections::BTreeMap;
2221
use std::collections::HashMap;
2322
use std::collections::HashSet;
@@ -488,13 +487,13 @@ pub struct ConfigFile {
488487
}
489488

490489
impl ConfigFile {
491-
pub fn discover(flags: &Flags, cwd: &Path) -> Result<Option<ConfigFile>, AnyError> {
490+
pub fn discover(_flags: &Flags, _cwd: &Path) -> Result<Option<ConfigFile>, AnyError> {
492491
Ok(None)
493492
}
494493

495494
pub fn discover_from(
496-
start: &Path,
497-
checked: &mut HashSet<PathBuf>,
495+
_start: &Path,
496+
_checked: &mut HashSet<PathBuf>,
498497
) -> Result<Option<ConfigFile>, AnyError> {
499498
// No config file found.
500499
Ok(None)

crates/module_fetcher/src/args/lockfile.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
22
use deno_core::error::AnyError;
3-
use std::path::PathBuf;
43

5-
use crate::args::config_file::{ConfigFile, LockConfig};
4+
use crate::args::config_file::ConfigFile;
65
use crate::npm::NpmResolutionPackage;
76

87
use crate::args::flags::Flags;
@@ -12,8 +11,8 @@ use deno_lockfile::NpmPackageDependencyLockfileInfo;
1211
use deno_lockfile::NpmPackageLockfileInfo;
1312

1413
pub fn discover(
15-
flags: &Flags,
16-
maybe_config_file: Option<&ConfigFile>,
14+
_flags: &Flags,
15+
_maybe_config_file: Option<&ConfigFile>,
1716
) -> Result<Option<Lockfile>, AnyError> {
1817
// if flags.no_lock
1918
// || matches!(

0 commit comments

Comments
 (0)