flora is a fast and secure runtime that lets you write discord bots for your servers, with a rich TypeScript SDK, without worrying about running infrastructure. [mirror]
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(runtime): use static-embed to embed frontend

+157 -85
+149 -27
Cargo.lock
··· 23 23 source = "registry+https://github.com/rust-lang/crates.io-index" 24 24 checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" 25 25 dependencies = [ 26 - "crypto-common", 26 + "crypto-common 0.1.7", 27 27 "generic-array", 28 28 ] 29 29 ··· 511 511 ] 512 512 513 513 [[package]] 514 + name = "block-buffer" 515 + version = "0.12.0" 516 + source = "registry+https://github.com/rust-lang/crates.io-index" 517 + checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" 518 + dependencies = [ 519 + "hybrid-array", 520 + ] 521 + 522 + [[package]] 514 523 name = "bool_to_bitflags" 515 524 version = "0.1.3" 516 525 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 731 740 dependencies = [ 732 741 "cfg-if", 733 742 "cipher", 734 - "cpufeatures", 743 + "cpufeatures 0.2.17", 735 744 ] 736 745 737 746 [[package]] ··· 767 776 source = "registry+https://github.com/rust-lang/crates.io-index" 768 777 checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" 769 778 dependencies = [ 770 - "crypto-common", 779 + "crypto-common 0.1.7", 771 780 "inout", 772 781 "zeroize", 773 782 ] ··· 891 900 checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 892 901 893 902 [[package]] 903 + name = "const-oid" 904 + version = "0.10.2" 905 + source = "registry+https://github.com/rust-lang/crates.io-index" 906 + checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" 907 + 908 + [[package]] 894 909 name = "cooked-waker" 895 910 version = "5.0.0" 896 911 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 953 968 ] 954 969 955 970 [[package]] 971 + name = "cpufeatures" 972 + version = "0.3.0" 973 + source = "registry+https://github.com/rust-lang/crates.io-index" 974 + checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" 975 + dependencies = [ 976 + "libc", 977 + ] 978 + 979 + [[package]] 956 980 name = "crc" 957 981 version = "3.4.0" 958 982 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1054 1078 ] 1055 1079 1056 1080 [[package]] 1081 + name = "crypto-common" 1082 + version = "0.2.1" 1083 + source = "registry+https://github.com/rust-lang/crates.io-index" 1084 + checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" 1085 + dependencies = [ 1086 + "hybrid-array", 1087 + ] 1088 + 1089 + [[package]] 1057 1090 name = "darling" 1058 1091 version = "0.20.11" 1059 1092 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1353 1386 "quinn", 1354 1387 "rustls-tokio-stream", 1355 1388 "serde", 1356 - "sha2", 1389 + "sha2 0.10.9", 1357 1390 "socket2 0.5.10", 1358 1391 "thiserror 2.0.18", 1359 1392 "tokio", ··· 1571 1604 source = "registry+https://github.com/rust-lang/crates.io-index" 1572 1605 checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" 1573 1606 dependencies = [ 1574 - "const-oid", 1607 + "const-oid 0.9.6", 1575 1608 "pem-rfc7468", 1576 1609 "zeroize", 1577 1610 ] ··· 1642 1675 source = "registry+https://github.com/rust-lang/crates.io-index" 1643 1676 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 1644 1677 dependencies = [ 1645 - "block-buffer", 1646 - "const-oid", 1647 - "crypto-common", 1678 + "block-buffer 0.10.4", 1679 + "const-oid 0.9.6", 1680 + "crypto-common 0.1.7", 1648 1681 "subtle", 1682 + ] 1683 + 1684 + [[package]] 1685 + name = "digest" 1686 + version = "0.11.2" 1687 + source = "registry+https://github.com/rust-lang/crates.io-index" 1688 + checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" 1689 + dependencies = [ 1690 + "block-buffer 0.12.0", 1691 + "const-oid 0.10.2", 1692 + "crypto-common 0.2.1", 1649 1693 ] 1650 1694 1651 1695 [[package]] ··· 1708 1752 "redox_users", 1709 1753 "winapi", 1710 1754 ] 1755 + 1756 + [[package]] 1757 + name = "display_full_error" 1758 + version = "1.1.0" 1759 + source = "registry+https://github.com/rust-lang/crates.io-index" 1760 + checksum = "bc7c47e9a2fd28a8edd1446f10dabe8ac5d26bb77ed2b1077bfcd8308904e8c6" 1711 1761 1712 1762 [[package]] 1713 1763 name = "displaydoc" ··· 1976 2026 "serde", 1977 2027 "serde_json", 1978 2028 "serenity", 1979 - "sha2", 2029 + "sha2 0.10.9", 1980 2030 "sqlx 0.8.6", 2031 + "static-serve", 1981 2032 "sys_traits", 1982 2033 "t0x", 1983 2034 "t0x-macros", ··· 2532 2583 source = "registry+https://github.com/rust-lang/crates.io-index" 2533 2584 checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 2534 2585 dependencies = [ 2535 - "digest", 2586 + "digest 0.10.7", 2536 2587 ] 2537 2588 2538 2589 [[package]] ··· 2618 2669 checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" 2619 2670 2620 2671 [[package]] 2672 + name = "hybrid-array" 2673 + version = "0.4.10" 2674 + source = "registry+https://github.com/rust-lang/crates.io-index" 2675 + checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214" 2676 + dependencies = [ 2677 + "typenum", 2678 + ] 2679 + 2680 + [[package]] 2621 2681 name = "hyper" 2622 2682 version = "0.14.32" 2623 2683 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3248 3308 checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" 3249 3309 dependencies = [ 3250 3310 "cfg-if", 3251 - "digest", 3311 + "digest 0.10.7", 3252 3312 ] 3253 3313 3254 3314 [[package]] ··· 4340 4400 source = "registry+https://github.com/rust-lang/crates.io-index" 4341 4401 checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" 4342 4402 dependencies = [ 4343 - "cpufeatures", 4403 + "cpufeatures 0.2.17", 4344 4404 "opaque-debug", 4345 4405 "universal-hash", 4346 4406 ] ··· 4568 4628 ] 4569 4629 4570 4630 [[package]] 4631 + name = "range-requests" 4632 + version = "0.2.0" 4633 + source = "registry+https://github.com/rust-lang/crates.io-index" 4634 + checksum = "a80a58719403473ceb7fed3cf4dc84ca007dbeec7a7b686151c6f82a18a4f9ac" 4635 + dependencies = [ 4636 + "axum-core 0.5.6", 4637 + "bytes", 4638 + "http 1.4.0", 4639 + "thiserror 2.0.18", 4640 + ] 4641 + 4642 + [[package]] 4571 4643 name = "rayon" 4572 4644 version = "1.11.0" 4573 4645 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4847 4919 source = "registry+https://github.com/rust-lang/crates.io-index" 4848 4920 checksum = "40a0376c50d0358279d9d643e4bf7b7be212f1f4ff1da9070a7b54d22ef75c88" 4849 4921 dependencies = [ 4850 - "const-oid", 4851 - "digest", 4922 + "const-oid 0.9.6", 4923 + "digest 0.10.7", 4852 4924 "num-bigint-dig", 4853 4925 "num-integer", 4854 4926 "num-traits", ··· 5273 5345 checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" 5274 5346 dependencies = [ 5275 5347 "cfg-if", 5276 - "cpufeatures", 5277 - "digest", 5348 + "cpufeatures 0.2.17", 5349 + "digest 0.10.7", 5278 5350 ] 5279 5351 5280 5352 [[package]] ··· 5284 5356 checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" 5285 5357 dependencies = [ 5286 5358 "cfg-if", 5287 - "cpufeatures", 5288 - "digest", 5359 + "cpufeatures 0.2.17", 5360 + "digest 0.10.7", 5361 + ] 5362 + 5363 + [[package]] 5364 + name = "sha2" 5365 + version = "0.11.0" 5366 + source = "registry+https://github.com/rust-lang/crates.io-index" 5367 + checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" 5368 + dependencies = [ 5369 + "cfg-if", 5370 + "cpufeatures 0.3.0", 5371 + "digest 0.11.2", 5289 5372 ] 5290 5373 5291 5374 [[package]] ··· 5329 5412 source = "registry+https://github.com/rust-lang/crates.io-index" 5330 5413 checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" 5331 5414 dependencies = [ 5332 - "digest", 5415 + "digest 0.10.7", 5333 5416 "rand_core 0.6.4", 5334 5417 ] 5335 5418 ··· 5528 5611 "serde", 5529 5612 "serde_json", 5530 5613 "sha1", 5531 - "sha2", 5614 + "sha2 0.10.9", 5532 5615 "smallvec", 5533 5616 "sqlformat", 5534 5617 "sqlx-rt", ··· 5567 5650 "rustls 0.23.28", 5568 5651 "serde", 5569 5652 "serde_json", 5570 - "sha2", 5653 + "sha2 0.10.9", 5571 5654 "smallvec", 5572 5655 "thiserror 2.0.18", 5573 5656 "tokio", ··· 5590 5673 "once_cell", 5591 5674 "proc-macro2", 5592 5675 "quote", 5593 - "sha2", 5676 + "sha2 0.10.9", 5594 5677 "sqlx-core 0.6.3", 5595 5678 "sqlx-rt", 5596 5679 "syn 1.0.109", ··· 5625 5708 "quote", 5626 5709 "serde", 5627 5710 "serde_json", 5628 - "sha2", 5711 + "sha2 0.10.9", 5629 5712 "sqlx-core 0.8.6", 5630 5713 "sqlx-mysql", 5631 5714 "sqlx-postgres", ··· 5648 5731 "bytes", 5649 5732 "chrono", 5650 5733 "crc", 5651 - "digest", 5734 + "digest 0.10.7", 5652 5735 "dotenvy", 5653 5736 "either", 5654 5737 "futures-channel", ··· 5669 5752 "rsa", 5670 5753 "serde", 5671 5754 "sha1", 5672 - "sha2", 5755 + "sha2 0.10.9", 5673 5756 "smallvec", 5674 5757 "sqlx-core 0.8.6", 5675 5758 "stringprep", ··· 5708 5791 "rand 0.8.5", 5709 5792 "serde", 5710 5793 "serde_json", 5711 - "sha2", 5794 + "sha2 0.10.9", 5712 5795 "smallvec", 5713 5796 "sqlx-core 0.8.6", 5714 5797 "stringprep", ··· 5762 5845 checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" 5763 5846 5764 5847 [[package]] 5848 + name = "static-serve" 5849 + version = "0.6.1" 5850 + source = "registry+https://github.com/rust-lang/crates.io-index" 5851 + checksum = "1f57f0b71026b8bf12d7d66e819f2258b209a4b14a1acdeed4602b48d1d97b35" 5852 + dependencies = [ 5853 + "axum 0.8.8", 5854 + "bytes", 5855 + "range-requests", 5856 + "static-serve-macro", 5857 + ] 5858 + 5859 + [[package]] 5860 + name = "static-serve-macro" 5861 + version = "0.6.1" 5862 + source = "registry+https://github.com/rust-lang/crates.io-index" 5863 + checksum = "9c4f9078e7a4de554122a49d6e0ff5a183192b471f6d4abfbd6e3755bf4d5d2a" 5864 + dependencies = [ 5865 + "display_full_error", 5866 + "flate2", 5867 + "glob", 5868 + "mime_guess", 5869 + "proc-macro2", 5870 + "quote", 5871 + "sha2 0.11.0", 5872 + "syn 2.0.117", 5873 + "thiserror 2.0.18", 5874 + "zstd", 5875 + ] 5876 + 5877 + [[package]] 5765 5878 name = "static_assertions" 5766 5879 version = "1.1.0" 5767 5880 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 6773 6886 source = "registry+https://github.com/rust-lang/crates.io-index" 6774 6887 checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" 6775 6888 dependencies = [ 6776 - "crypto-common", 6889 + "crypto-common 0.1.7", 6777 6890 "subtle", 6778 6891 ] 6779 6892 ··· 7838 7951 "potential_utf", 7839 7952 "resb", 7840 7953 "serde", 7954 + ] 7955 + 7956 + [[package]] 7957 + name = "zstd" 7958 + version = "0.13.3" 7959 + source = "registry+https://github.com/rust-lang/crates.io-index" 7960 + checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" 7961 + dependencies = [ 7962 + "zstd-safe", 7841 7963 ] 7842 7964 7843 7965 [[package]]
+1
Cargo.toml
··· 95 95 "uuid" 96 96 ] } 97 97 utoipa-scalar = { version = "0.3.0", features = ["axum"] } 98 + static-serve = { version = "0.6", features = [] } 98 99 uuid = { version = "1.21.0", features = ["v4"] } 99 100 100 101 [patch.crates-io]
+1
apps/runtime/Cargo.toml
··· 52 52 time.workspace = true 53 53 tokio.workspace = true 54 54 tokio-stream.workspace = true 55 + static-serve.workspace = true 55 56 tower-http.workspace = true 56 57 tower-layer.workspace = true 57 58 tower-service.workspace = true
+5 -56
apps/runtime/src/handlers/mod.rs
··· 1 1 use axum::{ 2 2 Json, Router, 3 - extract::{DefaultBodyLimit, Request}, 3 + extract::DefaultBodyLimit, 4 4 routing::get, 5 5 }; 6 - #[cfg(not(debug_assertions))] 7 - use axum::{ 8 - http::{HeaderValue, header}, 9 - middleware::{self, Next}, 10 - response::Response, 11 - }; 12 6 use tower_http::compression::CompressionLayer; 13 - #[cfg(not(debug_assertions))] 14 - use tower_http::services::{ServeDir, ServeFile}; 15 7 use utoipa::OpenApi; 16 8 use utoipa_scalar::{Scalar, Servable as ScalarServable}; 17 9 ··· 30 22 pub mod secrets; 31 23 pub mod tokens; 32 24 33 - #[cfg(not(debug_assertions))] 34 - const ASSET_CACHE_CONTROL: &str = "public, max-age=31536000, immutable"; 35 - #[cfg(not(debug_assertions))] 36 - const FRONTEND_CACHE_CONTROL: &str = "public, max-age=3600"; 37 - #[cfg(not(debug_assertions))] 38 - const HTML_CACHE_CONTROL: &str = "no-cache"; 39 - 40 - #[cfg(not(debug_assertions))] 41 - async fn set_asset_cache_headers(req: Request, next: Next) -> Response { 42 - let mut response = next.run(req).await; 43 - response.headers_mut().insert( 44 - header::CACHE_CONTROL, 45 - HeaderValue::from_static(ASSET_CACHE_CONTROL), 46 - ); 47 - response 48 - } 49 - 50 - #[cfg(not(debug_assertions))] 51 - async fn set_frontend_cache_headers(req: Request, next: Next) -> Response { 52 - let path = req.uri().path(); 53 - let is_html = path == "/" || path.ends_with(".html") || !path.contains('.'); 54 - let is_service_worker = path == "/sw.js"; 55 - let mut response = next.run(req).await; 56 - let header_value = if is_html || is_service_worker { 57 - HTML_CACHE_CONTROL 58 - } else { 59 - FRONTEND_CACHE_CONTROL 60 - }; 61 - response.headers_mut().insert( 62 - header::CACHE_CONTROL, 63 - HeaderValue::from_static(header_value), 64 - ); 65 - response 66 - } 67 - 68 25 /// Build the top-level router with API routes and interactive docs. 69 26 pub fn create_router() -> Router<AppState> { 70 27 #[derive(OpenApi)] ··· 122 79 123 80 #[cfg(not(debug_assertions))] 124 81 { 125 - let assets_router = Router::new() 126 - .fallback_service(ServeDir::new("apps/frontend/dist/assets")) 127 - .layer(middleware::from_fn(set_asset_cache_headers)); 82 + use static_serve::{embed_asset, embed_assets}; 128 83 129 - let frontend_router = Router::new() 130 - .fallback_service( 131 - ServeDir::new("apps/frontend/dist") 132 - .fallback(ServeFile::new("apps/frontend/dist/index.html")), 133 - ) 134 - .layer(middleware::from_fn(set_frontend_cache_headers)); 84 + embed_assets!("apps/frontend/dist", compress = true, cache_busted_paths = ["assets"], allow_unknown_extensions = true); 85 + let index_handler = embed_asset!("apps/frontend/dist/index.html", compress = true); 135 86 136 - return router 137 - .nest("/assets", assets_router) 138 - .fallback_service(frontend_router); 87 + return router.merge(static_router()).fallback(index_handler); 139 88 } 140 89 141 90 #[cfg(debug_assertions)]
+1 -2
vite.config.ts
··· 49 49 } 50 50 }, 51 51 staged: { 52 - '*': 'vp check --fix', 53 - '*.rs': 'cargo fmt' 52 + '*': 'vp check --fix' 54 53 }, 55 54 fmt: { 56 55 quoteProps: 'preserve',