diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ec9501f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.github +.vscode +migrations +target +.dockerignore +.env* +.gitignore +.rustfmt.toml +docker-compose.yml +Dockerfile +Makefile.toml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..895235b --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +FRONTEND_URl="http://localhost:3000" +DATABASE_URL="postgres://admin:securepassword@localhost:5432/benchmarks" +PORT=47143 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b38bb2f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: Format, Lint, and Build + +on: + push: + branches: [main] + paths-ignore: ["**.md"] + pull_request: + paths-ignore: ["**.md"] + +env: + CARGO_TERM_COLOR: always + +jobs: + suite: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Register Problem Matchers + uses: r7kamura/rust-problem-matchers@v1 + + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt,clippy + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install Cargo Make + uses: davidB/rust-cargo-make@v1 + + - name: Run Formatter + run: cargo +nightly fmt --all -- --check + + - name: Run Clippy + run: cargo +nightly clippy --tests --examples --all-targets --all-features --workspace -- -D warnings + + - name: Build + run: cargo build --release diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 911b71e..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Deploy - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - name: Deploy - steps: - - uses: actions/checkout@v3 - - name: Deploy - uses: cloudflare/wrangler-action@v3 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - command: deploy --keep-vars diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4295c94..481597f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Deploy Docker Image on: - # push: - # branches: [main] + push: + branches: [main] workflow_dispatch: env: @@ -32,7 +32,7 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Login to Google Container Registry + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io diff --git a/.gitignore b/.gitignore index abb6976..448b3c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -.wrangler -build -node_modules target -.dev.vars -dist +.env* +!.env.example diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c1cce5e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-toml + - id: check-yaml + - id: pretty-format-json + args: ["--indent=4", "--autofix", "--no-sort-keys"] + # - id: check-added-large-files + + - repo: local + hooks: + - id: format + name: format + description: Format files with rustfmt. + entry: makers fmt + language: system + types: [rust] + pass_filenames: false + - id: lint + name: lint + description: Lint files with Clippy. + entry: makers lint + language: system + types: [rust] + pass_filenames: false + - id: check + name: check + description: Check files with Cargo Check + entry: cargo check + language: system + types: [rust] + pass_filenames: false diff --git a/.sqlx/query-0a7d9181f68c17b127e98b93e2ee627309710dcc3fbcc4512c1f547d5c9529b1.json b/.sqlx/query-0a7d9181f68c17b127e98b93e2ee627309710dcc3fbcc4512c1f547d5c9529b1.json new file mode 100644 index 0000000..a7dfa05 --- /dev/null +++ b/.sqlx/query-0a7d9181f68c17b127e98b93e2ee627309710dcc3fbcc4512c1f547d5c9529b1.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "insert into shortcode(code, mode, data) values ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Int4", + "Text" + ] + }, + "nullable": [] + }, + "hash": "0a7d9181f68c17b127e98b93e2ee627309710dcc3fbcc4512c1f547d5c9529b1" +} diff --git a/.sqlx/query-8cfc0fc5de6ef323a99c26405107e74718be44bdda10a2283bc6fd06442c4632.json b/.sqlx/query-8cfc0fc5de6ef323a99c26405107e74718be44bdda10a2283bc6fd06442c4632.json new file mode 100644 index 0000000..c53cfce --- /dev/null +++ b/.sqlx/query-8cfc0fc5de6ef323a99c26405107e74718be44bdda10a2283bc6fd06442c4632.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "select code from shortcode where code = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "code", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "8cfc0fc5de6ef323a99c26405107e74718be44bdda10a2283bc6fd06442c4632" +} diff --git a/.sqlx/query-94c45d8cd456dbab107c17b7fbd0abfdeb69102c933da8e9d00764d2fbe1942b.json b/.sqlx/query-94c45d8cd456dbab107c17b7fbd0abfdeb69102c933da8e9d00764d2fbe1942b.json new file mode 100644 index 0000000..1f9df7a --- /dev/null +++ b/.sqlx/query-94c45d8cd456dbab107c17b7fbd0abfdeb69102c933da8e9d00764d2fbe1942b.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "select data, mode as \"mode: ShortlinkMode\" from shortcode WHERE code = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "data", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "mode: ShortlinkMode", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false + ] + }, + "hash": "94c45d8cd456dbab107c17b7fbd0abfdeb69102c933da8e9d00764d2fbe1942b" +} diff --git a/Cargo.lock b/Cargo.lock index 6dc608d..5e57353 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,19 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -26,6 +39,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "async-trait" version = "0.1.77" @@ -34,7 +53,26 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-write-file" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcdbedc2236483ab103a53415653d6b4442ea6141baf1ffa85df29635e88436" +dependencies = [ + "nix", + "rand", ] [[package]] @@ -43,6 +81,74 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "axum" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -64,12 +170,27 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -79,12 +200,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - [[package]] name = "byteorder" version = "1.5.0" @@ -113,57 +228,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "chrono" -version = "0.4.31" +name = "const-oid" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "js-sys", - "num-traits", - "wasm-bindgen", -] +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] -name = "chrono-tz" -version = "0.8.5" +name = "cpufeatures" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d7b79e99bfaa0d47da0687c43aa3b7381938a62ad3a6498599039321f660b7" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ - "chrono", - "chrono-tz-build", - "phf", + "libc", ] [[package]] -name = "chrono-tz-build" -version = "0.2.1" +name = "crc" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ - "parse-zoneinfo", - "phf", - "phf_codegen", + "crc-catalog", ] [[package]] -name = "console_error_panic_hook" -version = "0.1.7" +name = "crc-catalog" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if", - "wasm-bindgen", -] +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] -name = "cpufeatures" -version = "0.2.12" +name = "crossbeam-queue" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "libc", + "crossbeam-utils", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crypto-common" version = "0.1.6" @@ -175,12 +283,14 @@ dependencies = [ ] [[package]] -name = "deranged" -version = "0.3.11" +name = "der" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ - "powerfmt", + "const-oid", + "pem-rfc7468", + "zeroize", ] [[package]] @@ -190,15 +300,64 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] [[package]] -name = "fallible-iterator" -version = "0.2.0" +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "fastrand" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "finl_unicode" @@ -206,6 +365,17 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -238,22 +408,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] -name = "futures-io" +name = "futures-executor" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] [[package]] -name = "futures-macro" -version = "0.3.30" +name = "futures-intrusive" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ - "proc-macro2", - "quote", - "syn", + "futures-core", + "lock_api", + "parking_lot", ] +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + [[package]] name = "futures-sink" version = "0.3.30" @@ -274,7 +455,6 @@ checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", - "futures-macro", "futures-sink", "futures-task", "memchr", @@ -300,10 +480,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -313,239 +491,502 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] -name = "hmac" -version = "0.12.1" +name = "h2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "31d030e59af851932b72ceebadf4a2b5986dba4c3b99dd2493f8273a0f151943" dependencies = [ - "digest", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] -name = "http" -version = "0.2.11" +name = "hashbrown" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "bytes", - "fnv", - "itoa", + "ahash", + "allocator-api2", ] [[package]] -name = "http" -version = "1.0.0" +name = "hashlink" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "bytes", - "fnv", - "itoa", + "hashbrown", ] [[package]] -name = "idna" -version = "0.5.0" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "unicode-segmentation", ] [[package]] -name = "indoc" -version = "2.0.4" +name = "hermit-abi" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] -name = "itoa" -version = "1.0.10" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "js-sys" -version = "0.3.63" +name = "hkdf" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "wasm-bindgen", + "hmac", ] [[package]] -name = "jsbm-dev" -version = "0.1.0" +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "base64", - "cfg-if", - "console_error_panic_hook", - "http 1.0.0", - "indoc", - "rand", - "serde", - "serde_json", - "serde_repr", - "time", - "tokio-postgres", - "wasm-bindgen", - "worker", + "digest", ] [[package]] -name = "libc" -version = "0.2.152" +name = "home" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] [[package]] -name = "lock_api" -version = "0.4.11" +name = "http" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" dependencies = [ - "autocfg", - "scopeguard", + "bytes", + "fnv", + "itoa", ] [[package]] -name = "log" -version = "0.4.20" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] [[package]] -name = "matchit" -version = "0.4.6" +name = "http-body-util" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9376a4f0340565ad675d11fc1419227faf5f60cd7ac9cb2e7185a471f30af833" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] [[package]] -name = "md-5" -version = "0.10.6" +name = "httparse" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest", -] +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] -name = "memchr" -version = "2.7.1" +name = "httpdate" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "miniz_oxide" -version = "0.7.1" +name = "hyper" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" dependencies = [ - "adler", + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", ] [[package]] -name = "num-traits" -version = "0.2.17" +name = "hyper-util" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ - "autocfg", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", ] [[package]] -name = "object" -version = "0.32.2" +name = "idna" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "memchr", + "unicode-bidi", + "unicode-normalization", ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "indexmap" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +dependencies = [ + "equivalent", + "hashbrown", +] [[package]] -name = "parking_lot" +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + +[[package]] +name = "itertools" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ - "lock_api", - "parking_lot_core", + "either", ] [[package]] -name = "parking_lot_core" -version = "0.9.9" +name = "itoa" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "jsbm-dev" +version = "0.2.0" +dependencies = [ + "axum", + "base64", + "http", + "indoc", + "rand", + "serde", + "serde_json", + "sqlx", + "tokio", + "tower-http", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libsqlite3-sys" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.2", "cfg-if", "libc", - "redox_syscall", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", "smallvec", - "windows-targets", + "zeroize", ] [[package]] -name = "parse-zoneinfo" -version = "0.3.0" +name = "num-integer" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "regex", + "autocfg", + "num-traits", ] [[package]] -name = "percent-encoding" -version = "2.3.1" +name = "num-iter" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] [[package]] -name = "phf" -version = "0.11.2" +name = "num-traits" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ - "phf_shared", + "autocfg", + "libm", ] [[package]] -name = "phf_codegen" -version = "0.11.2" +name = "num_cpus" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "phf_generator", - "phf_shared", + "hermit-abi", + "libc", ] [[package]] -name = "phf_generator" -version = "0.11.2" +name = "object" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ - "phf_shared", - "rand", + "memchr", ] [[package]] -name = "phf_shared" -version = "0.11.2" +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "overload" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "siphasher", + "lock_api", + "parking_lot_core", ] +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + [[package]] name = "pin-project" version = "1.1.3" @@ -563,7 +1004,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -579,40 +1020,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "postgres-protocol" -version = "0.6.6" +name = "pkcs1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "base64", - "byteorder", - "bytes", - "fallible-iterator", - "getrandom", - "hmac", - "md-5", - "memchr", - "rand", - "sha2", - "stringprep", + "der", + "pkcs8", + "spki", ] [[package]] -name = "postgres-types" -version = "0.2.6" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2234cdee9408b523530a9b6d2d6b373d1db34f6a8e51dc03ded1828d7fb67c" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "bytes", - "fallible-iterator", - "postgres-protocol", + "der", + "spki", ] [[package]] -name = "powerfmt" -version = "0.2.0" +name = "pkg-config" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "ppv-lite86" @@ -674,7 +1106,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -685,8 +1117,17 @@ checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata", - "regex-syntax", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -697,21 +1138,110 @@ checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.2", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "ring" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted", + "windows-sys 0.48.0", +] + +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustix" +version = "0.38.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +dependencies = [ + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.16" @@ -725,34 +1255,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "serde" -version = "1.0.195" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-wasm-bindgen" -version = "0.5.0" +name = "sct" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", + "ring", + "untrusted", ] [[package]] -name = "serde-wasm-bindgen" -version = "0.6.3" +name = "serde" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b713f70513ae1f8d92665bbbbda5c295c2cf1da5542881ae5eefe20c9af132" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", + "serde_derive", ] [[package]] @@ -763,7 +1281,7 @@ checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] @@ -778,14 +1296,13 @@ dependencies = [ ] [[package]] -name = "serde_repr" -version = "0.1.18" +name = "serde_path_to_error" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" +checksum = "ebd154a240de39fdebcf5775d2675c204d7c13cf39a4c697be6493c8e734337c" dependencies = [ - "proc-macro2", - "quote", - "syn", + "itoa", + "serde", ] [[package]] @@ -800,6 +1317,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -812,10 +1340,32 @@ dependencies = [ ] [[package]] -name = "siphasher" -version = "0.3.11" +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] [[package]] name = "slab" @@ -827,19 +1377,255 @@ dependencies = [ ] [[package]] -name = "smallvec" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" - -[[package]] -name = "socket2" -version = "0.5.5" +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce81b7bd7c4493975347ef60d8c7e8b742d4694f4c49f93e0a12ea263938176c" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" +dependencies = [ + "ahash", + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" +dependencies = [ + "atomic-write-file", + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" +dependencies = [ + "atoi", + "base64", + "bitflags 2.4.2", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" +dependencies = [ + "atoi", + "base64", + "bitflags 2.4.2", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" dependencies = [ - "libc", - "windows-sys", + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", + "urlencoding", ] [[package]] @@ -859,6 +1645,17 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.48" @@ -870,6 +1667,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "tempfile" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.52.0", +] + [[package]] name = "thiserror" version = "1.0.56" @@ -887,28 +1703,19 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.48", ] [[package]] -name = "time" -version = "0.3.31" +name = "thread_local" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ - "deranged", - "js-sys", - "powerfmt", - "serde", - "time-core", + "cfg-if", + "once_cell", ] -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - [[package]] name = "tinyvec" version = "1.6.0" @@ -926,39 +1733,42 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", + "libc", + "mio", + "num_cpus", "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", ] [[package]] -name = "tokio-postgres" -version = "0.7.10" +name = "tokio-macros" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d340244b32d920260ae7448cb72b6e238bddc3d4f7603394e7dd46ed8e48f5b8" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ - "async-trait", - "byteorder", - "bytes", - "fallible-iterator", - "futures-channel", - "futures-util", - "log", - "parking_lot", - "percent-encoding", - "phf", + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", "pin-project-lite", - "postgres-protocol", - "postgres-types", - "rand", - "socket2", "tokio", - "tokio-util", - "whoami", ] [[package]] @@ -975,16 +1785,76 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da193277a4e2c33e59e09b5861580c33dd0a637c3883d0fa74ba40c0374af2e" +dependencies = [ + "bitflags 2.4.2", + "bytes", + "http", + "http-body", + "http-body-util", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", + "uuid", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ + "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -992,6 +1862,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", ] [[package]] @@ -1021,6 +1934,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.0" @@ -1033,115 +1964,77 @@ dependencies = [ ] [[package]] -name = "version_check" -version = "0.9.4" +name = "urlencoding" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +name = "uuid" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +dependencies = [ + "getrandom", +] [[package]] -name = "wasm-bindgen" -version = "0.2.87" +name = "valuable" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" +name = "vcpkg" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] -name = "wasm-bindgen-futures" -version = "0.4.36" +name = "version_check" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" +name = "webpki-roots" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" +name = "whoami" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" [[package]] -name = "wasm-streams" -version = "0.3.0" +name = "winapi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "futures-util", - "js-sys", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] -name = "web-sys" -version = "0.3.63" +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "whoami" -version = "1.4.1" +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" -dependencies = [ - "wasm-bindgen", - "web-sys", -] +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" @@ -1149,7 +2042,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -1158,13 +2060,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1173,36 +2090,72 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -1210,72 +2163,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "worker" -version = "0.0.18" -source = "git+https://github.com/cloudflare/workers-rs#c57f7a6d31da601397e46daec5a9448d6efbe1cc" -dependencies = [ - "async-trait", - "chrono", - "chrono-tz", - "futures-channel", - "futures-util", - "http 0.2.11", - "js-sys", - "matchit", - "pin-project", - "serde", - "serde-wasm-bindgen 0.6.3", - "serde_json", - "serde_urlencoded", - "tokio", - "tokio-postgres", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-streams", - "web-sys", - "worker-kv", - "worker-macros", - "worker-sys", -] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] -name = "worker-kv" -version = "0.6.0" +name = "zerocopy" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d4b9fe1a87b7aef252fceb4f30bf6303036a5de329c81ccad9be9c35d1fdbc7" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ - "js-sys", - "serde", - "serde-wasm-bindgen 0.5.0", - "serde_json", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", + "zerocopy-derive", ] [[package]] -name = "worker-macros" -version = "0.0.10" -source = "git+https://github.com/cloudflare/workers-rs#c57f7a6d31da601397e46daec5a9448d6efbe1cc" +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ - "async-trait", "proc-macro2", "quote", - "syn", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-macro-support", - "worker-sys", + "syn 2.0.48", ] [[package]] -name = "worker-sys" -version = "0.0.10" -source = "git+https://github.com/cloudflare/workers-rs#c57f7a6d31da601397e46daec5a9448d6efbe1cc" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" diff --git a/Cargo.toml b/Cargo.toml index b578489..830e8f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,40 +1,39 @@ [package] name = "jsbm-dev" -version = "0.1.0" +version = "0.2.0" description = "Benchmark storage and redirecting Cloudflare Worker for JSBenchmark.com" -license = "MIT-OR-Apache-2.0" +license = "MIT OR Apache-2.0" authors = ["Carter Himmel "] repository = "https://github.com/jsbenchmark/jsbm.dev" edition = "2021" -[package.metadata.wasm-pack.profile.release] -wasm-opt = false - -[lib] -crate-type = ["cdylib"] - [dependencies] -cfg-if = "1" -serde = "1.0.188" -worker = { git = "https://github.com/cloudflare/workers-rs", ref = "c57f7a6", features = [ - "tokio-postgres", - "d1", -] } -tokio-postgres = { version = "0.7", features = [ - 'js', -], default-features = false } -wasm-bindgen = "=0.2.87" -console_error_panic_hook = { version = "0.1", optional = true } +serde = { version = "1.0.188", features = ["derive"] } indoc = "2.0.4" http = "1.0.0" serde_json = "1.0.111" base64 = "0.21.7" -time = { version = "0.3", features = ["wasm-bindgen"] } -serde_repr = "0.1.18" rand = "0.8.5" - -[features] -default = ["console_error_panic_hook"] - -[profile.release] -opt-level = "s" +axum = { version = "0.7.4", features = ["tracing", "macros"] } +tokio = { version = "1.36.0", features = [ + "rt-multi-thread", + "macros", + "sync", + "signal", +] } +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = [ + "fmt", + "env-filter", + "json", +] } +tower-http = { version = "0.5.1", features = [ + "timeout", + "trace", + "request-id", +] } +sqlx = { version = "0.7.3", features = [ + "runtime-tokio", + "tls-rustls", + "postgres", +] } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a5d16db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Using the `rust-musl-builder` as base image, instead of +# the official Rust toolchain +FROM clux/muslrust:1.75.0 AS chef +USER root +RUN cargo install cargo-chef +WORKDIR /app + +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json +COPY . . +RUN cargo build --release --target x86_64-unknown-linux-musl --bin jsbm-dev --no-default-features + +FROM alpine AS runtime +WORKDIR /app +COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/jsbm-dev . + +RUN ls -la +CMD ["/app/jsbm-dev"] diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..7182414 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,31 @@ +[tasks.setup] +script = ''' + echo # installing git hooks + pre-commit --version || pip install pre-commit + pre-commit install || echo "failed to install git hooks!" 1>&2 +''' + +[tasks.dev] +command = "cargo" +args = ["run"] +env_files = ["./.env"] +watch = true + +[tasks.lint] +command = "cargo" +args = [ + "+nightly", + "clippy", + "--tests", + "--examples", + "--all-targets", + "--all-features", + "--workspace", +] + +[tasks.format] +command = "cargo" +args = ["+nightly", "fmt", "--all"] + +[tasks.fmt] +alias = "format" diff --git a/README.md b/README.md index 99b3081..4326cb7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jsbm.dev -> Benchmark storage and redirecting Cloudflare Worker for [JSBenchmark.com](https://jsbenchmark.com) +> Benchmark storage and redirecting API for [JSBenchmark.com](https://jsbenchmark.com) ## API @@ -79,32 +79,25 @@ interface ReplState { To get up-and-running in development, do the following: -1. Setup Wrangler +1. Clone `.env` -I use [`Volta`](https://volta.sh) but `npm i -g` works just as well. +The example file is `.env.example`. -```bash -$ volta install wrangler # or -$ npm i -g wrangler +```sh +$ cp .env.example .env ``` -Then, run `wrangler login` and follow the instructions. - -1. Clone `.dev.vars` +2. Start postgres -The example file is prefixed with an underscore. +Run `docker compose up --wait` to start postgres -```sh -$ cp _.dev.vars .dev.vars -``` +3. Run migrations -1. Start postgres (and pgbouncer) +Install the [`sqlx-cli`]() then run `sqlx migrate run`. -Run `docker compose up --wait` to start postgres and pgbouncer. -Pgbouncer is used to pool connections to the database, which is required for serverless. -The migrations are ran automatically. +4. Start the server -Neon, the database provider this project recommends in production, has a native pooling option, so this is only required for development. +`makers dev` ## Deployment diff --git a/_.dev.vars b/_.dev.vars deleted file mode 100644 index 8bac93b..0000000 --- a/_.dev.vars +++ /dev/null @@ -1,6 +0,0 @@ -ENVIRONMENT=development -PG_USER = "admin" -PG_PASSWORD = "securepassword" -PG_HOST = "localhost" -PG_DATABASE = "benchmarks" -FRONTEND_URL = "http://localhost:3000" diff --git a/docker-compose.yml b/docker-compose.yml index 7877b02..7f160b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,9 +9,8 @@ services: POSTGRES_DB: "benchmarks" volumes: - postgres-storage:/var/lib/postgresql/data - - ./migrations:/docker-entrypoint-initdb.d ports: - - "5532:5432" + - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] start_period: 20s @@ -20,19 +19,5 @@ services: timeout: 5s restart: unless-stopped - pgbouncer: - image: rmccaffrey/pgbouncer:latest - environment: - - DATABASE_URL=postgres://admin:securepassword@postgres:5432/benchmarks - - POOL_MODE=transaction - - MAX_DB_CONNECTIONS=100 - - DEFAULT_POOL_SIZE=40 - - AUTH_TYPE=scram-sha-256 - depends_on: - - postgres - ports: - - "5432:5432" - restart: unless-stopped - volumes: postgres-storage: diff --git a/migrations/0000_init.sql b/migrations/20240202155357_init.sql similarity index 95% rename from migrations/0000_init.sql rename to migrations/20240202155357_init.sql index 4088edf..c26138f 100644 --- a/migrations/0000_init.sql +++ b/migrations/20240202155357_init.sql @@ -1,4 +1,3 @@ --- Migration number: 0000 2024-01-20T01:25:05.928Z create table if not exists shortcode ( code text primary key, mode int not null default 0, diff --git a/src/error.rs b/src/error.rs index 7997275..d837911 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,13 +1,16 @@ +use std::error::Error as StdError; use std::fmt::Display; +use axum::response::{Html, IntoResponse, Json, Response}; use http::StatusCode; use indoc::formatdoc; use serde::Serialize; use serde_json::json; -use worker::*; + +pub type BoxDynError = Box; /// Creates a generic JSON response with the given status code and message. -pub fn create_error_json(status: StatusCode, message: Message) -> worker::Result +pub fn create_error_json(status: StatusCode, message: Message) -> Response where Message: Serialize { let canonical_reason = status.canonical_reason().unwrap_or("Unknown"); @@ -16,11 +19,11 @@ where Message: Serialize { "message": message }); - Ok(Response::from_json(&source)?.with_status(status.as_u16())) + (status, Json(source)).into_response() } /// Creates a generic HTML response with the given status code and message. -pub fn create_html_page(status: StatusCode, message: Message) -> worker::Result +pub fn create_html_page(status: StatusCode, message: Message) -> Response where Message: Display { let canonical_reason = status.canonical_reason().unwrap_or("Unknown"); @@ -48,5 +51,5 @@ where Message: Display { "#}; - Ok(Response::from_html(source)?.with_status(status.as_u16())) + (status, Html(source)).into_response() } diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 0a296b6..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,28 +0,0 @@ -use error::create_html_page; -use http::StatusCode; -use routes::create::create_shortcode; -use routes::select::select_shortcode; -use utils::log_request; -use worker::*; - -mod error; -mod model; -mod routes; -mod ser; -mod utils; - -#[event(fetch)] -async fn main(req: Request, env: Env, _ctx: Context) -> Result { - log_request(&req); - utils::set_panic_hook(); - - Router::new() - .get("/", |_, _| { - // todo: figure out what we wanna do here - create_html_page(StatusCode::OK, "Hello, world!") - }) - .get_async("/:shortcode", select_shortcode) - .post_async("/api/shortcode", create_shortcode) - .run(req, env) - .await -} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..9182219 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,92 @@ +use std::env::var; +use std::net::{Ipv4Addr, SocketAddrV4}; +use std::sync::Arc; +use std::time::Duration; + +use axum::extract::DefaultBodyLimit; +use axum::routing::{get, post}; +use axum::Router; +use error::{create_html_page, BoxDynError}; +use http::StatusCode; +use model::create_database; +use sqlx::PgPool; +use tokio::net::TcpListener; +use tower_http::timeout::TimeoutLayer; +use tower_http::trace::TraceLayer; +use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt, EnvFilter, Registry}; + +mod error; +mod model; +mod routes; +mod ser; + +use crate::routes::create::create_code; +use crate::routes::select::get_code; + +pub struct AppState { + db: Arc, + frontend_url: String, +} + +#[tokio::main] +async fn main() -> Result<(), BoxDynError> { + let port = var("PORT") + .map(|p| p.parse::().expect("failed to parse port")) + .unwrap_or_else(|_| 47143); + + let frontend_url = var("FRONTEND_URL").unwrap_or_else(|_| "http://localhost:3000".to_string()); + + Registry::default() + .with(EnvFilter::try_from_default_env().unwrap_or_else(|_| "debug,tower_http=debug,axum=trace".into())) + .with(fmt::layer()) + .init(); + + let db = create_database().await.expect("failed to create database connection"); + let state = Arc::new(AppState { db, frontend_url }); + + let app = Router::new() + .route("/", get(|| async { create_html_page(StatusCode::OK, "Hello, world!") })) + .route("/:code", get(get_code)) + .route("/api/shortcode", post(create_code)) + .with_state(state) + .layer(( + TraceLayer::new_for_http(), + TimeoutLayer::new(Duration::from_secs(10)), + DefaultBodyLimit::max(1024 * 100 /* 100kb */), + )); + + let socket = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), port); + tracing::info!("Listening on http://{socket}"); + let listener = TcpListener::bind(socket).await.expect("failed to bind tcp listener"); + + let _ = axum::serve(listener, app) + .with_graceful_shutdown(shutdown_signal()) + .await; + + Ok(()) +} + +async fn shutdown_signal() { + let ctrl_c = async { + tokio::signal::ctrl_c().await.expect("failed to install Ctrl+C handler"); + }; + + #[cfg(unix)] + let terminate = async { + tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()) + .expect("failed to install signal handler") + .recv() + .await; + }; + + #[cfg(not(unix))] + let terminate = std::future::pending::<()>(); + + tokio::select! { + _ = ctrl_c => {}, + _ = terminate => {}, + } + + tracing::info!("signal received, starting graceful shutdown"); +} diff --git a/src/model.rs b/src/model.rs index 99a61af..e0c07e4 100644 --- a/src/model.rs +++ b/src/model.rs @@ -1,15 +1,34 @@ -use std::error::Error as StdError; -use std::result::Result as StdResult; +use std::env::var; +use std::sync::Arc; +use std::time::Duration; use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; -use tokio_postgres::config::SslMode; -use tokio_postgres::types::{FromSql, Type}; -use worker::postgres_tls::PassthroughTls; -use worker::*; +use sqlx::postgres::{PgConnectOptions, PgPoolOptions}; +use sqlx::{ConnectOptions, PgPool}; -#[derive(Debug, Deserialize_repr, Serialize_repr)] -#[repr(u8)] +use crate::BoxDynError; + +/// Creates a new connection to the Postgres database. +pub async fn create_database() -> Result, BoxDynError> { + let database_url = var("DATABASE_URL")?; + + let pool = PgPoolOptions::new() + .max_connections(32) + .min_connections(4) + .acquire_timeout(Duration::from_secs(8)) + .idle_timeout(Duration::from_secs(8)) + .max_lifetime(Duration::from_secs(120)); + + let mut opts: PgConnectOptions = database_url.parse()?; + opts = opts.log_statements(tracing::log::LevelFilter::Debug); + + let db = pool.connect_with(opts).await?; + + Ok(Arc::new(db)) +} + +#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Serialize, Deserialize, sqlx::Type)] +#[repr(i32)] pub enum ShortlinkMode { Benchmark = 0, Repl = 1, @@ -22,26 +41,6 @@ impl ShortlinkMode { ShortlinkMode::Repl => 1, } } - - pub fn from_i32(i: i32) -> StdResult> { - match i { - 0 => Ok(ShortlinkMode::Benchmark), - 1 => Ok(ShortlinkMode::Repl), - _ => Err("invalid shortlink mode".into()), - } - } -} - -impl<'a> FromSql<'a> for ShortlinkMode { - fn from_sql(ty: &Type, raw: &'a [u8]) -> StdResult> { - let i = i32::from_sql(ty, raw)?; - - ShortlinkMode::from_i32(i) - } - - fn accepts(ty: &Type) -> bool { - i32::accepts(ty) - } } #[allow(dead_code)] @@ -51,36 +50,3 @@ pub struct ShortlinkRow { pub data: String, pub mode: ShortlinkMode, } - -/// Creates a new connection to the Postgres database. -pub async fn create_database(env: &Env) -> Result { - let mut config = tokio_postgres::config::Config::new(); - config.user(&env.secret("PG_USER")?.to_string()); - config.password(&env.secret("PG_PASSWORD")?.to_string()); - - if env - .var("ENVIRONMENT") - .map(|e| &e.to_string() == "production") - .unwrap_or(false) - { - config.ssl_mode(SslMode::Require); - } - - config.dbname(&env.secret("PG_DATABASE")?.to_string()); - - let socket = Socket::builder() - .secure_transport(SecureTransport::StartTls) - .connect(&env.secret("PG_HOST")?.to_string(), 5432)?; - let (client, connection) = config - .connect_raw(socket, PassthroughTls) - .await - .map_err(|e| worker::Error::RustError(format!("tokio-postgres: {e:#?}")))?; - - wasm_bindgen_futures::spawn_local(async move { - if let Err(error) = connection.await { - console_error!("postgres connection error: {error:#?}"); - } - }); - - Ok(client) -} diff --git a/src/routes/create.rs b/src/routes/create.rs index 1e7a2fd..5575067 100644 --- a/src/routes/create.rs +++ b/src/routes/create.rs @@ -1,81 +1,83 @@ +use std::sync::Arc; + +use axum::extract::State; +use axum::response::IntoResponse; +use axum::Json; use base64::engine::general_purpose::URL_SAFE; -use base64::Engine as _; +use base64::Engine; use http::StatusCode; -use serde::{Deserialize, Serialize}; -use worker::*; use rand::distributions::{Alphanumeric, DistString}; +use serde::{Deserialize, Serialize}; use crate::error::create_error_json; -use crate::model::{create_database, ShortlinkMode}; +use crate::model::ShortlinkMode; use crate::ser::{BenchmarkState, ReplState}; +use crate::AppState; #[derive(Debug, Serialize, Deserialize)] #[serde(untagged)] -enum CreateShortcodeJsonBody { +pub enum CreateShortcodeJsonBody { Benchmark(BenchmarkState), Repl(ReplState), } -fn generate_code() -> String { - let string = Alphanumeric.sample_string(&mut rand::thread_rng(), 13); - - string -} - -pub async fn create_shortcode(mut req: Request, ctx: RouteContext<()>) -> worker::Result { - let Ok(body) = req.json::().await else { - return create_error_json( - StatusCode::BAD_REQUEST, - "Body did not match benchmark or repl save schema", - ); - }; - +#[axum::debug_handler] +pub async fn create_code( + State(state): State>, + Json(body): Json, +) -> impl IntoResponse { let mode = match body { CreateShortcodeJsonBody::Benchmark(_) => ShortlinkMode::Benchmark, CreateShortcodeJsonBody::Repl(_) => ShortlinkMode::Repl, }; - let s = serde_json::to_vec(&body)?; + let Ok(s) = serde_json::to_vec(&body) else { + return create_error_json(StatusCode::INTERNAL_SERVER_ERROR, "Failed to serialize body").into_response(); + }; let data = URL_SAFE.encode(&s); // Limit data size to 100KB. if data.bytes().len() > 100_000 { - return create_error_json(StatusCode::PAYLOAD_TOO_LARGE, "Payload too large"); + return create_error_json(StatusCode::PAYLOAD_TOO_LARGE, "Payload too large").into_response(); } - let db = create_database(&ctx.env).await?; + #[inline] + fn generate_code() -> String { + Alphanumeric.sample_string(&mut rand::thread_rng(), 13) + } - // Generate a unique shortcode. let mut attempts = 0; let max_attempts = 10; let mut code = generate_code(); - while let Ok(Some(_)) = db - .query_opt("select code from shortcode where code = $1", &[&code]) + while let Ok(Some(_)) = sqlx::query!("select code from shortcode where code = $1", &code) + .fetch_optional(&*state.db) .await { code = generate_code(); attempts += 1; if attempts >= max_attempts { - return create_error_json( - StatusCode::INTERNAL_SERVER_ERROR, - "Failed to generate unique shortcode", - ); + return create_error_json(StatusCode::INTERNAL_SERVER_ERROR, "Failed to generate unique shortcode") + .into_response(); } } - if let Err(err) = db - .execute( - "insert into shortcode(code, mode, data) values ($1, $2, $3);", - &[&code, &mode.as_i32(), &data], - ) - .await + if let Err(err) = sqlx::query!( + "insert into shortcode(code, mode, data) values ($1, $2, $3)", + &code, + &mode.as_i32(), + &data + ) + .execute(&*state.db) + .await { - console_error!("Failed to insert shortcode: {err:#?}"); - return create_error_json(StatusCode::INTERNAL_SERVER_ERROR, "Failed to create shortcode"); - }; + tracing::error!("Failed to insert shortcode into database: {:?}", err); + return create_error_json( + StatusCode::INTERNAL_SERVER_ERROR, + "Failed to insert shortcode into database", + ) + .into_response(); + } - Response::from_json(&serde_json::json!({ - "code": code, - })) + (StatusCode::CREATED, Json(serde_json::json!({ "code": code }))).into_response() } diff --git a/src/routes/select.rs b/src/routes/select.rs index fa2b9ff..fe8e9ba 100644 --- a/src/routes/select.rs +++ b/src/routes/select.rs @@ -1,35 +1,36 @@ +use std::sync::Arc; + +use axum::extract::{Path, State}; +use axum::response::{IntoResponse, Redirect}; use http::StatusCode; -use worker::*; use crate::error::create_html_page; -use crate::model::{create_database, ShortlinkMode}; - -pub async fn select_shortcode(_: Request, ctx: RouteContext<()>) -> worker::Result { - let Some(shortcode) = ctx.param("shortcode") else { - return create_html_page(StatusCode::BAD_REQUEST, "No shortcode provided".to_string()); - }; +use crate::model::ShortlinkMode; +use crate::AppState; - let db = create_database(&ctx.env).await?; - let result = match db - .query_opt("select data, mode from shortcode WHERE code = $1", &[shortcode]) - .await +#[axum::debug_handler] +pub async fn get_code(State(state): State>, Path(code): Path) -> impl IntoResponse { + let result = match sqlx::query!( + r#"select data, mode as "mode: ShortlinkMode" from shortcode WHERE code = $1"#, + &code + ) + .fetch_optional(&*state.db) + .await { Ok(Some(result)) => result, - Ok(None) => return create_html_page(StatusCode::NOT_FOUND, "Shortcode not found".to_string()), + Ok(None) => return create_html_page(StatusCode::NOT_FOUND, "Shortcode not found".to_string()).into_response(), Err(e) => { - console_error!("Error querying database: {e:#?}"); - return create_html_page(StatusCode::INTERNAL_SERVER_ERROR, "An unknown error occurred"); + tracing::error!("Error querying database: {e:#?}"); + return create_html_page(StatusCode::INTERNAL_SERVER_ERROR, "An unknown error occurred").into_response(); } }; - let encoded_data: &str = result.get("data"); - let mode: ShortlinkMode = result.get("mode"); - - let frontend_url = ctx.env.var("FRONTEND_URL")?.to_string(); - let url = match mode { - ShortlinkMode::Benchmark => Url::parse(&format!("{frontend_url}/#{}", encoded_data))?, - ShortlinkMode::Repl => Url::parse(&format!("{frontend_url}/repl/#{}", encoded_data))?, + let frontend_url = &state.frontend_url; + let data = &result.data; + let url = match result.mode { + ShortlinkMode::Benchmark => format!("{frontend_url}/#{data}"), + ShortlinkMode::Repl => format!("{frontend_url}/repl/#{data}"), }; - Response::redirect(url) + Redirect::permanent(&url).into_response() } diff --git a/src/utils.rs b/src/utils.rs deleted file mode 100644 index a129991..0000000 --- a/src/utils.rs +++ /dev/null @@ -1,27 +0,0 @@ -use cfg_if::cfg_if; -use worker::{console_log, Date, Request}; - -cfg_if! { - // https://github.com/rustwasm/console_error_panic_hook#readme - if #[cfg(feature = "console_error_panic_hook")] { - extern crate console_error_panic_hook; - pub use self::console_error_panic_hook::set_once as set_panic_hook; - } else { - #[inline] - pub fn set_panic_hook() {} - } -} - -pub fn log_request(req: &Request) { - let cf = req.cf(); - - let region = cf.and_then(|cf| cf.region()).unwrap_or("unknown region".to_string()); - - console_log!( - "{} - [{}], located at: {:?}, within: {}", - Date::now().to_string(), - req.path(), - cf.map(|cf| cf.coordinates()).unwrap_or_default(), - region - ); -} diff --git a/wrangler.toml b/wrangler.toml deleted file mode 100644 index be8c0ca..0000000 --- a/wrangler.toml +++ /dev/null @@ -1,9 +0,0 @@ -name = "jsbm-dev" -main = "build/worker/shim.mjs" -compatibility_date = "2022-10-20" - -[build] -command = "cargo install -q worker-build --version 0.0.10 && worker-build --release" - -[vars] -ENVIRONMENT = "production"