From f48390b15ebbbbd23156f6d2c6c01da89f49b933 Mon Sep 17 00:00:00 2001 From: Jet Pham Date: Wed, 11 Mar 2026 13:00:51 -0700 Subject: [PATCH] feat: add project and email service --- .gitignore | 8 + api/Cargo.lock | 1606 +++++++++++++++++++++++++++++++++ api/Cargo.toml | 13 + api/src/email.rs | 61 ++ api/src/handlers.rs | 184 ++++ api/src/main.rs | 9 + api/src/rate_limit.rs | 35 + api/src/serve.rs | 55 ++ flake.nix | 8 + index.html | 72 +- module.nix | 55 +- package-lock.json | 133 +++ package.json | 2 + public/sitemap.xml | 10 + src/components/frosted-box.ts | 14 + src/content/projects/cgol.md | 10 + src/global.d.ts | 20 + src/lib/api.ts | 25 + src/main.ts | 15 +- src/pages/home.ts | 40 + src/pages/not-found.ts | 12 + src/pages/project.ts | 24 + src/pages/projects.ts | 22 + src/pages/qa.ts | 87 ++ src/router.ts | 68 ++ src/styles/globals.css | 69 +- tsconfig.json | 3 +- vite-plugin-markdown.ts | 32 + vite.config.ts | 2 + 29 files changed, 2631 insertions(+), 63 deletions(-) create mode 100644 api/Cargo.lock create mode 100644 api/Cargo.toml create mode 100644 api/src/email.rs create mode 100644 api/src/handlers.rs create mode 100644 api/src/main.rs create mode 100644 api/src/rate_limit.rs create mode 100644 api/src/serve.rs create mode 100644 src/components/frosted-box.ts create mode 100644 src/content/projects/cgol.md create mode 100644 src/lib/api.ts create mode 100644 src/pages/home.ts create mode 100644 src/pages/not-found.ts create mode 100644 src/pages/project.ts create mode 100644 src/pages/projects.ts create mode 100644 src/pages/qa.ts create mode 100644 src/router.ts create mode 100644 vite-plugin-markdown.ts diff --git a/.gitignore b/.gitignore index 33ec970..f2e426e 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,11 @@ yarn-error.log* /.direnv /result + +# rust +/api/target + +# sqlite +*.db +*.db-wal +*.db-shm diff --git a/api/Cargo.lock b/api/Cargo.lock new file mode 100644 index 0000000..0dea264 --- /dev/null +++ b/api/Cargo.lock @@ -0,0 +1,1606 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "ar_archive_writer" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb93bbb63b9c227414f6eb3a0adfddca591a8ce1e9b60661bb08969b87e340b" +dependencies = [ + "object", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "axum" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b52af3cb4058c895d37317bb27508dccc8e5f2d39454016b297bf4a400597b8" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chumsky" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eebd66744a15ded14960ab4ccdbfb51ad3b81f51f3f04a80adac98c985396c9" +dependencies = [ + "hashbrown 0.14.5", + "stacker", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "email-encoding" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9298e6504d9b9e780ed3f7dfd43a61be8cd0e09eb07f7706a945b0072b6670b6" +dependencies = [ + "base64", + "memchr", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jetpham-qa-api" +version = "0.1.0" +dependencies = [ + "axum", + "lettre", + "rusqlite", + "serde", + "serde_json", + "tokio", + "tower-http", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "lettre" +version = "0.11.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e13e10e8818f8b2a60f52cb127041d388b89f3a96a62be9ceaffa22262fef7f" +dependencies = [ + "base64", + "chumsky", + "email-encoding", + "email_address", + "fastrand", + "futures-util", + "hostname", + "httpdate", + "idna", + "mime", + "native-tls", + "nom", + "percent-encoding", + "quoted_printable", + "socket2", + "tokio", + "url", +] + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3852766467df634d74f0b2d7819bf8dc483a0eb2e3b0f50f756f9cfe8b0d18d8" +dependencies = [ + "ar_archive_writer", + "cc", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "quoted_printable" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "640c9bd8497b02465aeef5375144c26062e0dcd5939dfcbb0f5db76cb8c17c73" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rusqlite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stacker" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d74a23609d509411d10e2176dc2a4346e3b4aea2e7b1869f19fdedbc71c013" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "windows-sys 0.59.0", +] + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags", + "bytes", + "http", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/api/Cargo.toml b/api/Cargo.toml new file mode 100644 index 0000000..dc36f0d --- /dev/null +++ b/api/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "jetpham-qa-api" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum = "0.8" +lettre = "0.11" +rusqlite = { version = "0.32", features = ["bundled"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tokio = { version = "1", features = ["full"] } +tower-http = { version = "0.6", features = ["cors"] } diff --git a/api/src/email.rs b/api/src/email.rs new file mode 100644 index 0000000..4961df3 --- /dev/null +++ b/api/src/email.rs @@ -0,0 +1,61 @@ +use lettre::message::Mailbox; +use lettre::transport::smtp::client::Tls; +use lettre::{Message, SmtpTransport, Transport}; + +pub fn send_notification( + id: i64, + question: &str, + notify_email: &str, +) -> Result<(), Box> { + let truncated = if question.len() > 50 { + format!("{}...", &question[..50]) + } else { + question.to_string() + }; + + let from: Mailbox = "Q&A ".parse()?; + let reply_to: Mailbox = format!("qa+{id}@extremist.software").parse()?; + let to: Mailbox = notify_email.parse()?; + + let email = Message::builder() + .from(from) + .reply_to(reply_to) + .to(to) + .subject(format!("Q&A #{id}: {truncated}")) + .body(question.to_string())?; + + let mailer = SmtpTransport::builder_dangerous("localhost") + .tls(Tls::None) + .build(); + mailer.send(&email)?; + + Ok(()) +} + +pub fn strip_quoted_text(body: &str) -> String { + let mut result = Vec::new(); + for line in body.lines() { + if line.starts_with('>') { + continue; + } + if line.starts_with("On ") && line.ends_with("wrote:") { + break; + } + result.push(line); + } + result.join("\n").trim().to_string() +} + +pub fn extract_id_from_address(to: &str) -> Result> { + let addr = to.trim(); + let addr = if let Some(start) = addr.find('<') { + &addr[start + 1..addr.find('>').unwrap_or(addr.len())] + } else { + addr + }; + let local = addr.split('@').next().unwrap_or(""); + let id_str = local + .strip_prefix("qa+") + .ok_or("No qa+ prefix in address")?; + Ok(id_str.parse()?) +} diff --git a/api/src/handlers.rs b/api/src/handlers.rs new file mode 100644 index 0000000..6fd8e3b --- /dev/null +++ b/api/src/handlers.rs @@ -0,0 +1,184 @@ +use std::sync::Arc; + +use axum::extract::State; +use axum::http::{HeaderMap, StatusCode}; +use axum::Json; +use serde::{Deserialize, Serialize}; + +use crate::email; +use crate::serve::AppState; + +#[derive(Serialize)] +pub struct Question { + id: i64, + question: String, + answer: String, + created_at: String, + answered_at: String, +} + +pub async fn get_questions( + State(state): State>, +) -> Result>, StatusCode> { + let db = state.db.lock().map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + let mut stmt = db + .prepare( + "SELECT id, question, answer, created_at, answered_at \ + FROM questions WHERE answer IS NOT NULL \ + ORDER BY answered_at DESC", + ) + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + + let questions = stmt + .query_map([], |row| { + Ok(Question { + id: row.get(0)?, + question: row.get(1)?, + answer: row.get(2)?, + created_at: row.get(3)?, + answered_at: row.get(4)?, + }) + }) + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)? + .collect::, _>>() + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?; + + Ok(Json(questions)) +} + +#[derive(Deserialize)] +pub struct SubmitQuestion { + question: String, +} + +pub async fn post_question( + State(state): State>, + headers: HeaderMap, + Json(body): Json, +) -> Result { + if body.question.is_empty() || body.question.len() > 200 { + return Err(( + StatusCode::BAD_REQUEST, + "Question must be 1-200 characters".to_string(), + )); + } + + let ip = headers + .get("x-forwarded-for") + .and_then(|v| v.to_str().ok()) + .and_then(|s| s.split(',').next()) + .map(|s| s.trim().to_string()) + .unwrap_or_else(|| "unknown".to_string()); + + if !state.rate_limiter.check(&ip) { + return Err(( + StatusCode::TOO_MANY_REQUESTS, + "Too many questions. Try again later.".to_string(), + )); + } + + let id: i64 = { + let db = state + .db + .lock() + .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "db error".to_string()))?; + db.execute( + "INSERT INTO questions (question) VALUES (?1)", + rusqlite::params![body.question], + ) + .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "insert error".to_string()))?; + db.last_insert_rowid() + }; + + let notify_email = state.notify_email.clone(); + let question_text = body.question.clone(); + tokio::task::spawn_blocking(move || { + if let Err(e) = email::send_notification(id, &question_text, ¬ify_email) { + eprintln!("Failed to send notification: {e}"); + } + }); + + Ok(StatusCode::CREATED) +} + +// --- MTA Hook webhook types --- + +#[derive(Deserialize)] +pub struct MtaHookPayload { + #[serde(default)] + pub messages: Vec, +} + +#[derive(Deserialize)] +pub struct MtaHookMessage { + #[serde(default)] + pub envelope: Envelope, + #[serde(default)] + pub contents: String, +} + +#[derive(Deserialize, Default)] +pub struct Envelope { + #[serde(default)] + pub to: Vec, +} + +#[derive(Serialize)] +pub struct MtaHookResponse { + pub action: &'static str, +} + +pub async fn webhook( + State(state): State>, + headers: HeaderMap, + Json(payload): Json, +) -> Result, (StatusCode, String)> { + // Verify webhook secret + let secret = headers + .get("X-Webhook-Secret") + .and_then(|v| v.to_str().ok()) + .unwrap_or(""); + + if secret != state.webhook_secret { + return Err((StatusCode::UNAUTHORIZED, "invalid secret".to_string())); + } + + for message in &payload.messages { + // Find a qa+ recipient + let qa_recipient = message.envelope.to.iter().find(|addr| { + let local = addr.split('@').next().unwrap_or(""); + local.starts_with("qa+") + }); + + let recipient = match qa_recipient { + Some(r) => r, + None => continue, // not a Q&A reply, skip + }; + + let id = match email::extract_id_from_address(recipient) { + Ok(id) => id, + Err(_) => continue, + }; + + let body = email::strip_quoted_text(&message.contents); + if body.is_empty() { + continue; + } + + let db = state + .db + .lock() + .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "db error".to_string()))?; + db.execute( + "UPDATE questions SET answer = ?1, answered_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now') \ + WHERE id = ?2 AND answer IS NULL", + rusqlite::params![body, id], + ) + .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, "update error".to_string()))?; + + return Ok(Json(MtaHookResponse { action: "discard" })); + } + + // No Q&A recipient matched — let Stalwart deliver normally + Ok(Json(MtaHookResponse { action: "accept" })) +} diff --git a/api/src/main.rs b/api/src/main.rs new file mode 100644 index 0000000..805a457 --- /dev/null +++ b/api/src/main.rs @@ -0,0 +1,9 @@ +mod email; +mod handlers; +mod rate_limit; +mod serve; + +#[tokio::main] +async fn main() { + serve::run().await.expect("server error"); +} diff --git a/api/src/rate_limit.rs b/api/src/rate_limit.rs new file mode 100644 index 0000000..3557031 --- /dev/null +++ b/api/src/rate_limit.rs @@ -0,0 +1,35 @@ +use std::collections::HashMap; +use std::sync::Mutex; +use std::time::Instant; + +pub struct RateLimiter { + max_requests: u32, + window_secs: u64, + clients: Mutex>, +} + +impl RateLimiter { + pub fn new(max_requests: u32, window_secs: u64) -> Self { + Self { + max_requests, + window_secs, + clients: Mutex::new(HashMap::new()), + } + } + + pub fn check(&self, ip: &str) -> bool { + let mut clients = self.clients.lock().unwrap(); + let now = Instant::now(); + + let entry = clients.entry(ip.to_string()).or_insert((0, now)); + if now.duration_since(entry.1).as_secs() >= self.window_secs { + *entry = (1, now); + return true; + } + if entry.0 >= self.max_requests { + return false; + } + entry.0 += 1; + true + } +} diff --git a/api/src/serve.rs b/api/src/serve.rs new file mode 100644 index 0000000..4439c8b --- /dev/null +++ b/api/src/serve.rs @@ -0,0 +1,55 @@ +use std::sync::{Arc, Mutex}; + +use axum::routing::{get, post}; +use axum::Router; +use rusqlite::Connection; +use tower_http::cors::CorsLayer; + +use crate::handlers; +use crate::rate_limit::RateLimiter; + +pub struct AppState { + pub db: Mutex, + pub notify_email: String, + pub rate_limiter: RateLimiter, + pub webhook_secret: String, +} + +pub async fn run() -> Result<(), Box> { + let db_path = std::env::var("QA_DB_PATH").unwrap_or_else(|_| "qa.db".to_string()); + let notify_email = std::env::var("QA_NOTIFY_EMAIL").expect("QA_NOTIFY_EMAIL must be set"); + let webhook_secret = std::env::var("WEBHOOK_SECRET").expect("WEBHOOK_SECRET must be set"); + + let conn = Connection::open(&db_path)?; + conn.execute_batch("PRAGMA journal_mode=WAL;")?; + conn.execute_batch( + "CREATE TABLE IF NOT EXISTS questions ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + question TEXT NOT NULL, + answer TEXT, + created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')), + answered_at TEXT + );", + )?; + + let state = Arc::new(AppState { + db: Mutex::new(conn), + notify_email, + rate_limiter: RateLimiter::new(5, 3600), + webhook_secret, + }); + + let app = Router::new() + .route( + "/api/questions", + get(handlers::get_questions).post(handlers::post_question), + ) + .route("/api/webhook", post(handlers::webhook)) + .layer(CorsLayer::permissive()) + .with_state(state); + + let listener = tokio::net::TcpListener::bind("127.0.0.1:3001").await?; + println!("Listening on 127.0.0.1:3001"); + axum::serve(listener, app).await?; + Ok(()) +} diff --git a/flake.nix b/flake.nix index 015555d..da49c1d 100644 --- a/flake.nix +++ b/flake.nix @@ -77,10 +77,18 @@ runHook postInstall ''; }; + qa-api = pkgs.rustPlatform.buildRustPackage { + pname = "jetpham-qa-api"; + version = "0.1.0"; + src = ./api; + cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + }; + in { packages = { default = website; cgol-wasm = cgol-wasm; + inherit qa-api; }; devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ diff --git a/index.html b/index.html index 1de783c..70f11c3 100644 --- a/index.html +++ b/index.html @@ -71,8 +71,8 @@ }, "sameAs": [ "https://github.com/jetpham", - "https://x.com/jetpham5", - "https://bsky.app/profile/jetpham.com", + "https://x.com/exmistsoftware", + "https://bsky.app/profile/extremist.software", "https://git.extremist.software" ] } @@ -80,62 +80,22 @@ -
-
- -
- - - -
-
-
-

Jet Pham

- -

Software Extremist

-
-
- A picture of Jet wearing a beanie in purple and blue lighting -
-
- -
- Contact - jet@extremist.software -
- -
- Links -
    -
  1. - Forgejo -
  2. -
  3. - GitHub -
  4. -
  5. - X -
  6. -
  7. - Bluesky -
  8. -
-
-
+
+ +
diff --git a/module.nix b/module.nix index e865f6e..7eecb7a 100644 --- a/module.nix +++ b/module.nix @@ -4,6 +4,7 @@ self: let cfg = config.services.jetpham-website; package = self.packages.x86_64-linux.default; + qaApi = self.packages.x86_64-linux.qa-api; in { options.services.jetpham-website = { @@ -14,15 +15,65 @@ in default = "jetpham.com"; description = "Domain to serve the website on."; }; + + envFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "Environment file containing QA_NOTIFY_EMAIL."; + }; + + qaMailDomain = lib.mkOption { + type = lib.types.str; + default = "extremist.software"; + description = "Mail domain for Q&A reply addresses."; + }; + + webhookSecretFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + description = "File containing the WEBHOOK_SECRET for MTA Hook authentication."; + }; }; config = lib.mkIf cfg.enable { + # Q&A API systemd service + systemd.services.jetpham-qa-api = { + description = "Jet Pham Q&A API"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + DynamicUser = true; + StateDirectory = "jetpham-qa"; + Environment = [ "QA_DB_PATH=/var/lib/jetpham-qa/qa.db" ]; + Restart = "on-failure"; + RestartSec = 5; + } // lib.optionalAttrs (cfg.webhookSecretFile == null) { + ExecStart = "${qaApi}/bin/jetpham-qa-api"; + } // lib.optionalAttrs (cfg.envFile != null) { + EnvironmentFile = cfg.envFile; + } // lib.optionalAttrs (cfg.webhookSecretFile != null) { + LoadCredential = "webhook-secret:${cfg.webhookSecretFile}"; + }; + script = lib.mkIf (cfg.webhookSecretFile != null) '' + export WEBHOOK_SECRET="$(cat $CREDENTIALS_DIRECTORY/webhook-secret)" + exec ${qaApi}/bin/jetpham-qa-api + ''; + }; + services.caddy.virtualHosts.${cfg.domain} = { extraConfig = '' header Cross-Origin-Opener-Policy "same-origin" header Cross-Origin-Embedder-Policy "require-corp" - root * ${package} - file_server + + handle /api/* { + reverse_proxy 127.0.0.1:3001 + } + + handle { + root * ${package} + try_files {path} /index.html + file_server + } ''; }; }; diff --git a/package-lock.json b/package-lock.json index eb9f1ce..9a389de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,8 @@ "anser": "^2.3.5", "escape-carriage": "^1.3.1", "eslint": "^10", + "gray-matter": "^4.0.3", + "marked": "^15.0.12", "prettier": "^3.8.1", "prettier-plugin-tailwindcss": "^0.7.2", "tailwindcss": "^4.2.1", @@ -1877,6 +1879,16 @@ "dev": true, "license": "MIT" }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -2150,6 +2162,20 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/esquery": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", @@ -2196,6 +2222,19 @@ "node": ">=0.10.0" } }, + "node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2334,6 +2373,22 @@ "dev": true, "license": "ISC" }, + "node_modules/gray-matter": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", + "integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-yaml": "^3.13.1", + "kind-of": "^6.0.2", + "section-matter": "^1.0.0", + "strip-bom-string": "^1.0.0" + }, + "engines": { + "node": ">=6.0" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -2354,6 +2409,16 @@ "node": ">=0.8.19" } }, + "node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2404,6 +2469,20 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/js-yaml": { + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.2.tgz", + "integrity": "sha512-PMSmkqxr106Xa156c2M265Z+FTrPl+oxd/rgOQy2tijQeK5TxQ43psO1ZCwhVOSdnn+RzkzlRz/eY4BgJBYVpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -2435,6 +2514,16 @@ "json-buffer": "3.0.1" } }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -2736,6 +2825,19 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/marked": { + "version": "15.0.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-15.0.12.tgz", + "integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==", + "dev": true, + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -3094,6 +3196,20 @@ "fsevents": "~2.3.2" } }, + "node_modules/section-matter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", + "integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "extend-shallow": "^2.0.1", + "kind-of": "^6.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/semver": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", @@ -3140,6 +3256,23 @@ "node": ">=0.10.0" } }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/strip-bom-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", + "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/tailwindcss": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.1.tgz", diff --git a/package.json b/package.json index b3819be..2131baa 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "anser": "^2.3.5", "escape-carriage": "^1.3.1", "eslint": "^10", + "gray-matter": "^4.0.3", + "marked": "^15.0.12", "prettier": "^3.8.1", "prettier-plugin-tailwindcss": "^0.7.2", "tailwindcss": "^4.2.1", diff --git a/public/sitemap.xml b/public/sitemap.xml index 8e86b77..8b55b3c 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -5,4 +5,14 @@ monthly 1.0 + + https://jetpham.com/projects + monthly + 0.8 + + + https://jetpham.com/qa + weekly + 0.8 + diff --git a/src/components/frosted-box.ts b/src/components/frosted-box.ts new file mode 100644 index 0000000..86b8f9c --- /dev/null +++ b/src/components/frosted-box.ts @@ -0,0 +1,14 @@ +export function frostedBox(content: string, extraClasses?: string): string { + return ` +
+ + +
+ ${content} +
+
`; +} diff --git a/src/content/projects/cgol.md b/src/content/projects/cgol.md new file mode 100644 index 0000000..a183399 --- /dev/null +++ b/src/content/projects/cgol.md @@ -0,0 +1,10 @@ +--- +title: Conway's Game of Life +description: WebAssembly implementation of Conway's Game of Life, running as the background of this website. +--- + +The background animation on this site is a WebAssembly implementation of +Conway's Game of Life, written in Rust and compiled to WASM. + +It runs directly in your browser using the HTML5 Canvas API, simulating +cellular automata in real-time. diff --git a/src/global.d.ts b/src/global.d.ts index 145ad9e..9193a96 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -14,3 +14,23 @@ declare module "*.utf8ans?raw" { const content: string; export default content; } + +declare module "virtual:projects" { + interface Project { + slug: string; + title: string; + description: string; + html: string; + } + const projects: Project[]; + export default projects; +} + +declare module "gray-matter" { + interface GrayMatterResult { + data: Record; + content: string; + } + function matter(input: string): GrayMatterResult; + export = matter; +} diff --git a/src/lib/api.ts b/src/lib/api.ts new file mode 100644 index 0000000..79b458a --- /dev/null +++ b/src/lib/api.ts @@ -0,0 +1,25 @@ +export interface Question { + id: number; + question: string; + answer: string; + created_at: string; + answered_at: string; +} + +export async function getQuestions(): Promise { + const res = await fetch("/api/questions"); + if (!res.ok) throw new Error("Failed to fetch questions"); + return res.json() as Promise; +} + +export async function submitQuestion(question: string): Promise { + const res = await fetch("/api/questions", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ question }), + }); + if (!res.ok) { + if (res.status === 429) throw new Error("Too many questions. Please try again later."); + throw new Error("Failed to submit question"); + } +} diff --git a/src/main.ts b/src/main.ts index e0f2984..4bb48e6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,17 @@ import "~/styles/globals.css"; -import Jet from "~/assets/Jet.txt?ansi"; import init, { start } from "cgol"; +import { route, initRouter } from "~/router"; +import { homePage } from "~/pages/home"; +import { projectsPage } from "~/pages/projects"; +import { projectPage } from "~/pages/project"; +import { qaPage } from "~/pages/qa"; +import { notFoundPage } from "~/pages/not-found"; -document.getElementById("ansi-art")!.innerHTML = Jet; +route("/", homePage); +route("/projects", projectsPage); +route("/projects/:slug", projectPage); +route("/qa", qaPage); +route("*", notFoundPage); try { await init(); @@ -10,3 +19,5 @@ try { } catch (e) { console.error("WASM init failed:", e); } + +initRouter(); diff --git a/src/pages/home.ts b/src/pages/home.ts new file mode 100644 index 0000000..4afc83f --- /dev/null +++ b/src/pages/home.ts @@ -0,0 +1,40 @@ +import Jet from "~/assets/Jet.txt?ansi"; +import { frostedBox } from "~/components/frosted-box"; + +export function homePage(outlet: HTMLElement) { + outlet.innerHTML = ` +
+ ${frostedBox(` +
+
+

Jet Pham

+ +

Software Extremist

+
+
+ A picture of Jet wearing a beanie in purple and blue lighting +
+
+
+ Contact + jet@extremist.software +
+
+ Links +
    +
  1. Forgejo
  2. +
  3. GitHub
  4. +
  5. X
  6. +
  7. Bluesky
  8. +
+
+ `)} +
`; +} diff --git a/src/pages/not-found.ts b/src/pages/not-found.ts new file mode 100644 index 0000000..0534b6f --- /dev/null +++ b/src/pages/not-found.ts @@ -0,0 +1,12 @@ +import { frostedBox } from "~/components/frosted-box"; + +export function notFoundPage(outlet: HTMLElement) { + outlet.innerHTML = ` +
+ ${frostedBox(` +

404

+

Page not found.

+

[BACK TO HOME]

+ `)} +
`; +} diff --git a/src/pages/project.ts b/src/pages/project.ts new file mode 100644 index 0000000..04af49e --- /dev/null +++ b/src/pages/project.ts @@ -0,0 +1,24 @@ +import projects from "virtual:projects"; +import { frostedBox } from "~/components/frosted-box"; + +export function projectPage(outlet: HTMLElement, params: Record) { + const project = projects.find((p) => p.slug === params.slug); + if (!project) { + outlet.innerHTML = ` +
+ ${frostedBox(` +

Project not found

+

[BACK TO PROJECTS]

+ `)} +
`; + return; + } + + outlet.innerHTML = ` +
+ ${frostedBox(` +

${project.title}

+
${project.html}
+ `)} +
`; +} diff --git a/src/pages/projects.ts b/src/pages/projects.ts new file mode 100644 index 0000000..e022f7c --- /dev/null +++ b/src/pages/projects.ts @@ -0,0 +1,22 @@ +import projects from "virtual:projects"; +import { frostedBox } from "~/components/frosted-box"; + +export function projectsPage(outlet: HTMLElement) { + const list = projects + .map( + (p) => ` +
  • + ${p.title} +

    ${p.description}

    +
  • `, + ) + .join(""); + + outlet.innerHTML = ` +
    + ${frostedBox(` +

    Projects

    +
      ${list}
    + `)} +
    `; +} diff --git a/src/pages/qa.ts b/src/pages/qa.ts new file mode 100644 index 0000000..9cbda4c --- /dev/null +++ b/src/pages/qa.ts @@ -0,0 +1,87 @@ +import { getQuestions, submitQuestion } from "~/lib/api"; +import { frostedBox } from "~/components/frosted-box"; + +function escapeHtml(str: string): string { + const div = document.createElement("div"); + div.textContent = str; + return div.innerHTML; +} + +export async function qaPage(outlet: HTMLElement) { + outlet.innerHTML = ` +
    + ${frostedBox(` +

    Q&A

    +
    +
    + Ask a Question + +
    + 0/200 + +
    +

    +
    +
    +
    Loading...
    + `)} +
    `; + + const form = document.getElementById("qa-form") as HTMLFormElement; + const input = document.getElementById("qa-input") as HTMLTextAreaElement; + const charCount = document.getElementById("char-count")!; + const status = document.getElementById("qa-status")!; + const list = document.getElementById("qa-list")!; + + input.addEventListener("input", () => { + charCount.textContent = `${input.value.length}/200`; + }); + + form.addEventListener("submit", (e) => { + e.preventDefault(); + const question = input.value.trim(); + if (!question) return; + + status.textContent = "Submitting..."; + status.style.color = "var(--light-gray)"; + + submitQuestion(question) + .then(() => { + input.value = ""; + charCount.textContent = "0/200"; + status.textContent = "Question submitted! It will appear here once answered."; + status.style.color = "var(--light-green)"; + }) + .catch((err: unknown) => { + status.textContent = err instanceof Error ? err.message : "Failed to submit question."; + status.style.color = "var(--light-red)"; + }); + }); + + try { + const questions = await getQuestions(); + if (questions.length === 0) { + list.textContent = "No questions answered yet."; + list.style.color = "var(--dark-gray)"; + } else { + list.innerHTML = questions + .map( + (q) => ` +
    + #${String(q.id)} +

    ${escapeHtml(q.question)}

    +

    ${escapeHtml(q.answer)}

    +

    + Asked ${q.created_at} · Answered ${q.answered_at} +

    +
    `, + ) + .join(""); + } + } catch { + list.textContent = "Failed to load questions."; + list.style.color = "var(--light-red)"; + } +} diff --git a/src/router.ts b/src/router.ts new file mode 100644 index 0000000..a78b093 --- /dev/null +++ b/src/router.ts @@ -0,0 +1,68 @@ +type PageHandler = ( + outlet: HTMLElement, + params: Record, +) => void | Promise; + +interface Route { + pattern: RegExp; + keys: string[]; + handler: PageHandler; +} + +const routes: Route[] = []; +let notFoundHandler: PageHandler | null = null; + +export function route(path: string, handler: PageHandler) { + if (path === "*") { + notFoundHandler = handler; + return; + } + const keys: string[] = []; + const pattern = path.replace(/:(\w+)/g, (_, key: string) => { + keys.push(key); + return "([^/]+)"; + }); + routes.push({ pattern: new RegExp(`^${pattern}$`), keys, handler }); +} + +export function navigate(path: string) { + history.pushState(null, "", path); + void render(); +} + +async function render() { + const path = location.pathname; + const outlet = document.getElementById("outlet")!; + + for (const r of routes) { + const match = path.match(r.pattern); + if (match) { + const params: Record = {}; + r.keys.forEach((key, i) => { + params[key] = match[i + 1]!; + }); + outlet.innerHTML = ""; + await r.handler(outlet, params); + return; + } + } + + outlet.innerHTML = ""; + if (notFoundHandler) { + await notFoundHandler(outlet, {}); + } +} + +export function initRouter() { + window.addEventListener("popstate", () => void render()); + + document.addEventListener("click", (e) => { + const anchor = (e.target as HTMLElement).closest("a"); + if (anchor?.origin === location.origin && !anchor.hasAttribute("download")) { + e.preventDefault(); + navigate(anchor.pathname); + } + }); + + void render(); +} diff --git a/src/styles/globals.css b/src/styles/globals.css index 566f7b2..253d106 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -82,5 +82,70 @@ a:hover { color: var(--blue); } - - + + /* Form inputs */ + .qa-textarea { + width: 100%; + background-color: var(--black); + border: 1px solid var(--white); + color: var(--light-gray); + padding: 1ch; + resize: none; + font-family: inherit; + font-size: inherit; + line-height: inherit; + } + + .qa-button { + border: 1px solid var(--white); + padding: 0 1ch; + color: var(--yellow); + background: transparent; + font-family: inherit; + font-size: inherit; + cursor: pointer; + } + + .qa-button:hover { + background-color: var(--yellow); + color: var(--black); + } + + /* Project markdown content */ + .project-content h2 { + color: var(--light-cyan); + margin-top: 2ch; + margin-bottom: 1ch; + } + + .project-content h3 { + color: var(--light-green); + margin-top: 1.5ch; + margin-bottom: 0.5ch; + } + + .project-content p { + margin-bottom: 1ch; + } + + .project-content ul, + .project-content ol { + margin-left: 2ch; + margin-bottom: 1ch; + } + + .project-content code { + color: var(--yellow); + } + + .project-content pre { + border: 1px solid var(--dark-gray); + padding: 1ch; + overflow-x: auto; + margin-bottom: 1ch; + } + + .project-content a { + color: var(--light-blue); + } + diff --git a/tsconfig.json b/tsconfig.json index 9204bff..706181b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,8 @@ "include": [ "src", "vite.config.ts", - "vite-plugin-ansi.ts" + "vite-plugin-ansi.ts", + "vite-plugin-markdown.ts" ], "exclude": [ "node_modules", diff --git a/vite-plugin-markdown.ts b/vite-plugin-markdown.ts new file mode 100644 index 0000000..2914eda --- /dev/null +++ b/vite-plugin-markdown.ts @@ -0,0 +1,32 @@ +import fs from "node:fs"; +import path from "node:path"; +import matter from "gray-matter"; +import { marked } from "marked"; +import type { Plugin } from "vite"; + +export default function markdownPlugin(): Plugin { + const virtualModuleId = "virtual:projects"; + const resolvedId = "\0" + virtualModuleId; + const projectsDir = path.resolve("src/content/projects"); + + return { + name: "vite-plugin-markdown", + resolveId(id) { + if (id === virtualModuleId) return resolvedId; + }, + load(id) { + if (id !== resolvedId) return; + + const files = fs.readdirSync(projectsDir).filter((f) => f.endsWith(".md")); + const projects = files.map((file) => { + const raw = fs.readFileSync(path.join(projectsDir, file), "utf-8"); + const { data, content } = matter(raw); + const html = marked(content); + const slug = file.replace(".md", ""); + return { slug, ...data, html }; + }); + + return `export default ${JSON.stringify(projects)};`; + }, + }; +} diff --git a/vite.config.ts b/vite.config.ts index ef3f64c..0b3d1b3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,10 +4,12 @@ import wasm from "vite-plugin-wasm"; import topLevelAwait from "vite-plugin-top-level-await"; import { viteSingleFile } from "vite-plugin-singlefile"; import ansi from "./vite-plugin-ansi"; +import markdown from "./vite-plugin-markdown"; export default defineConfig({ plugins: [ ansi(), + markdown(), tailwindcss(), wasm(), topLevelAwait(),