{"id":13672052,"url":"https://github.com/softprops/fasttime","last_synced_at":"2025-03-21T07:30:21.770Z","repository":{"id":54168992,"uuid":"311372382","full_name":"softprops/fasttime","owner":"softprops","description":"⏱️ A Fastly serverless compute@edge runtime for running wasm applications locally","archived":false,"fork":false,"pushed_at":"2021-03-05T19:31:54.000Z","size":345,"stargazers_count":62,"open_issues_count":12,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-17T11:59:54.524Z","etag":null,"topics":["cli","fastly","wasm","wasmtime"],"latest_commit_sha":null,"homepage":"http://localhost:3000","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softprops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-09T14:54:55.000Z","updated_at":"2025-02-02T13:07:53.000Z","dependencies_parsed_at":"2022-08-13T08:10:46.015Z","dependency_job_id":null,"html_url":"https://github.com/softprops/fasttime","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Ffasttime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Ffasttime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Ffasttime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softprops%2Ffasttime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softprops","download_url":"https://codeload.github.com/softprops/fasttime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244117675,"owners_count":20400743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","fastly","wasm","wasmtime"],"created_at":"2024-08-02T09:01:25.362Z","updated_at":"2025-03-21T07:30:21.322Z","avatar_url":"https://github.com/softprops.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  fasttime\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n   A lightweight Fastly \u003ca alt=\"GitHub Actions\" href=\"https://www.fastly.com/products/edge-compute/serverless/\"\u003eCompute@Edge\u003c/a\u003e runtime for running and testing \u003ca alt=\"wasm\" href=\"https://webassembly.org/\"\u003eWASM\u003c/a\u003e applications locally\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca alt=\"GitHub Actions\" href=\"https://github.com/softprops/fasttime/actions\"\u003e\n    \u003cimg src=\"https://github.com/softprops/fasttime/workflows/Main/badge.svg\"/\u003e\n  \u003c/a\u003e\n  \u003ca alt=\"license\" href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg\"/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n## about\n\nFastly allows you to run WASM request handlers within a WASI-based runtime hosted on its managed edge servers. `fasttime` implements those runtime interfaces using [wasmtime](https://wasmtime.dev/) serving up your application on a local HTTP server allowing you to run you Compute@Edge applications ✨ locally on your laptop ✨.\n\n## 🤸 usage\n\n### Building your app\n\nThe fastest way to get started with [Compute@Edge](https://www.fastly.com/products/edge-compute/serverless/) is though the [Fastly CLI](https://github.com/fastly/cli#installation)\n\n```sh\n$ fastly compute build\n```\n\nAlternatively, you can also build your WASM application using Rust's standard cargo tooling. \n\n\u003e Fastly assumes a Rust toolchain version of `1.46.0`\n\n```sh\n# optionally install 1.46.0 if you have not done so already\n$ rustup install 1.46.0 --profile minimal\n# optionally install the wasm32 toolchain if you have not done so already\n$ rustup target add wasm32-wasi --toolchain 1.46.0\n# build a release mode .wasm executable\n$ cargo +1.46.0 build --release --target wasm32-wasi\n```\n\nTo start fasttime, just provide it with the path to your Fastly Compute@Edge `.wasm` build artifact.\n\n### Serving up your app\n\n```sh\n$ fasttime -w target/wasm32-wasi/release/app.wasm\n```\n\nThis starts up a localhost HTTP server listening on port `3000` which you can interact with with\nan HTTP client like `curl`\n\n```sh\ncurl -i \"http://localhost:3000\"\n```\n\n#### ♻️ hot reloading\n\n`fasttime` can monitor your WASM applicaion for changes, and gracefully reload the module when needed allowing for live-editing. Using the `--watch` flag, there's no need to restart `fasttime` after running `fastly compute build`!\n\n```sh\n$ fasttime -w target/wasm32-wasi/release/app.wasm \\\n    --watch\n```\n\nThis pairs well with a `cargo watch` workflow. In another terminal, run\n\n```sh\n$ cargo +1.46.0 watch -x 'build --release --target wasm32-wasi'\n```\n\nYou can then make changes to your application in your text editor, have cargo automatically rebuild your application, and have `fasttime` automatically reload it as you develop your application\n\n#### ↔️ backends\n\nA common usecase for Fastly is proxying a set of backend hosts referred to by name. `fasttime` supports\nproviding multiple `-b | --backend` flags with values of the form `{backend}:{host}`. By default, if you\nsend a request to a backend that you have not mapped, a bad gateway response will be returned by the server.\n\n```sh\n$ fasttime -w target/wasm32-wasi/release/app.wasm \\\n    -b backend-two:localhost:3001 \\\n    -b backend-two:you.com\n```\n\n#### 📚 dictionaries\n\nA common way to look up key-value'd information in Fastly is to use [edge dictionaries](https://docs.fastly.com/en/guides/about-edge-dictionaries). `fasttime` supports providing multiple `-d | --dictionary` flags with values of the form `{dictionary}:{key}={value},{key2}={value2}`. \n\n```sh\n$ fasttime -w target/wasm32-wasi/release/app.wasm \\\n    -d dictionary-one:foo=bar \\\n    -d dictionary-two:baz=boom\n```\n\n#### 🪵 logging\n\nThe Compute@Edge runtime supports the notion of [remote logging endpoints](https://docs.fastly.com/en/guides/about-fastlys-realtime-log-streaming-features).\nThese are addressed by name within your applications.\n\n```rust\nuse fastly::log::Endpoint;\n\nlet mut endpoint = Endpoint::from_name(\"endpoint-name\");\nwriteln!(endpoint, \"hello {}\", \"wasm\");\n```\n\n`fasttime` currently support these by logging directly to stdout by default.\n\n#### 🤝 tls\n\nUsing a tls certificate making tool like [mkcert](https://github.com/FiloSottile/mkcert), create a new tls certificate and private key\n\n```sh\nmkcert -key-file key.pem -cert-file cert.pem 127.0.0.1 localhost\n```\n\nThen provide `--tls-cert` with a tls certifificate and `--tls-key` and tls private key to `fasttime`\n\n```sh\n$ fasttime -w target/wasm32-wasi/release/app.wasm \\\n    --tls-cert=./cert.pem \\\n    --tls-key=./key.pem\n```\n\n#### 🔍 debugging\n\nSet the `RUST_LOG` env variable to `fastime=debug` and run the cli as usual\n\n```\nRUST_LOG=fasttime=debug fasttime -w target/wasm32-wasi/release/app.wasm\n```\n\n#### ⚙️ configuration file\n\nAll settings can also be put in a configuration file which can be loaded from the commandline. Commandline arguments override any settings in the config file, except backends and dictionaries, which will be merged with entries from the commandline superceding those with the same key from the config file.\n\n```sh\n$ fasttime -c my_config.toml\n```\n\nExample config file:\n\n```toml\nwasm = \"my_app.wasm\"\nport = 3001\nwatch = true\ntls-cert = \"cert.pem\"\ntls-key = \"key.pem\"\n\n[[backend]]\nname = \"backend-one\"\naddress = \"example.net\"\n\n[[backend]]\nname = \"backend-two\"\naddress = \"example.com\"\n\n[[dictionary]]\nname = \"dictionary-one\"\n\n[dictionary.entries]\nhello = \"there\"\n\"key with a space\" = \"something\"\n\n[[dictionary]]\nname = \"dictionary-two\"\n\n[dictionary.entries]\napples = \"oranges\"\n```\n\n## 🚧 roadmap\n\n* list intentionally left blank.\n\nDoug Tangren (softprops) 2020\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Ffasttime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftprops%2Ffasttime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftprops%2Ffasttime/lists"}