-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace kv with cheaper alternative d1 (#5)
- Loading branch information
Showing
14 changed files
with
162 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
name: Checks | ||
|
||
# | ||
# NOTE: | ||
# everything under the 'checkout' step is temporary until I figure out how to use devenv.sh in gh actions | ||
# devenv has a guide for actions: https://devenv.sh/integrations/github-actions | ||
# but it doesn't work if you are using devenv this way: https://devenv.sh/guides/using-with-flakes | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
@@ -13,7 +19,6 @@ defaults: | |
|
||
env: | ||
NAME: 'url-shortener' | ||
CARGO_TERM_COLOR: 'always' | ||
ACTIONS_RUNNER_DEBUG: true | ||
|
||
jobs: | ||
|
@@ -23,21 +28,37 @@ jobs: | |
- name: 🔑 Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v30 | ||
- name: 🦀 Set up Rust | ||
uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
targets: wasm32-unknown-unknown | ||
components: rustc, cargo, rustfmt, clippy | ||
|
||
- name: Setup Rust Cache | ||
uses: Swatinem/[email protected] | ||
with: | ||
prefix-key: v0 # increment this to bust the cache if needed | ||
|
||
- name: Install sccache | ||
uses: mozilla-actions/[email protected] | ||
env: | ||
RUSTC_WRAPPER: 'sccache' | ||
SCCACHE_GHA_ENABLED: true | ||
|
||
- name: Setup Cachix | ||
uses: cachix/cachix-action@v15 | ||
- name: 🐰 Set up Bun | ||
uses: oven-sh/setup-bun@main | ||
with: | ||
name: 'devenv' | ||
bun-version: 'latest' | ||
|
||
- name: Install devenv.sh | ||
run: nix profile install nixpkgs#devenv | ||
- name: Format | ||
run: | | ||
bunx @taplo/cli@latest fmt *.toml | ||
cargo fmt --all --check | ||
- name: Lint | ||
run: | | ||
fmt | ||
lint | ||
bunx @taplo/cli@latest lint *.toml | ||
cargo clippy --all-targets --all-features -- -D warnings | ||
- name: Build | ||
run: build | ||
- name: 🛠️ Build worker | ||
run: cargo install --quiet worker-build && worker-build --release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# URL Shortener - Cloudflare Worker | ||
|
||
## Usage | ||
|
||
> [!NOTE] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
max_width = 100 | ||
reorder_imports = true | ||
imports_granularity = "Crate" | ||
group_imports = "StdExternalCrate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PRAGMA foreign_keys = OFF; | ||
DROP TABLE IF EXISTS urls; | ||
|
||
CREATE TABLE urls ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
url TEXT NOT NULL, | ||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# seed local d1 database with data | ||
|
||
urls=( | ||
"https://docs.union.build/reference/graphql/?query=%7B__typename%7D" | ||
"https://docs.union.build/reference/graphql/?query=%7B%0A%20%20v1_daily_transfers%20%7B%0A%20%20%20%20count%0A%20%20%20%20day%0A%20%20%7D%0A%7D" | ||
"https://docs.union.build/reference/graphql/?query=%7B%0A%20%20get_route(%0A%20%20%20%20args%3A%20%7Bdestination_chain_id%3A%20%22stride-internal-1%22%2C%20receiver%3A%20%22me%22%2C%20source_chain_id%3A%20%2211155111%22%2C%20forward_chain_id%3A%20%22union-testnet-8%22%7D%0A%20%20)%20%7B%0A%20%20%20%20memo%0A%20%20%7D%0A%7D" | ||
) | ||
|
||
for url in "${urls[@]}"; do | ||
d1-query --local --command="INSERT INTO urls (url) VALUES ('$url');" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters