Trading card city builder game?

configure dioxus app with server + sqlx

eldridge.cam 3cf5a51a 52adfeca

Waiting for spindle ...
+799 -185
+648 -2
Cargo.lock
··· 117 117 ] 118 118 119 119 [[package]] 120 + name = "atoi" 121 + version = "2.0.0" 122 + source = "registry+https://github.com/rust-lang/crates.io-index" 123 + checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" 124 + dependencies = [ 125 + "num-traits", 126 + ] 127 + 128 + [[package]] 120 129 name = "atomic-waker" 121 130 version = "1.1.2" 122 131 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 232 241 checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" 233 242 234 243 [[package]] 244 + name = "base64ct" 245 + version = "1.8.3" 246 + source = "registry+https://github.com/rust-lang/crates.io-index" 247 + checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" 248 + 249 + [[package]] 235 250 name = "bitflags" 236 251 version = "1.3.2" 237 252 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 321 336 version = "0.1.0" 322 337 dependencies = [ 323 338 "dioxus", 339 + "sqlx", 324 340 ] 325 341 326 342 [[package]] ··· 462 478 ] 463 479 464 480 [[package]] 481 + name = "concurrent-queue" 482 + version = "2.5.0" 483 + source = "registry+https://github.com/rust-lang/crates.io-index" 484 + checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" 485 + dependencies = [ 486 + "crossbeam-utils", 487 + ] 488 + 489 + [[package]] 490 + name = "const-oid" 491 + version = "0.9.6" 492 + source = "registry+https://github.com/rust-lang/crates.io-index" 493 + checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" 494 + 495 + [[package]] 465 496 name = "const-serialize" 466 497 version = "0.7.2" 467 498 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 651 682 ] 652 683 653 684 [[package]] 685 + name = "crc" 686 + version = "3.4.0" 687 + source = "registry+https://github.com/rust-lang/crates.io-index" 688 + checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" 689 + dependencies = [ 690 + "crc-catalog", 691 + ] 692 + 693 + [[package]] 694 + name = "crc-catalog" 695 + version = "2.4.0" 696 + source = "registry+https://github.com/rust-lang/crates.io-index" 697 + checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" 698 + 699 + [[package]] 654 700 name = "crc32fast" 655 701 version = "1.5.0" 656 702 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 664 710 version = "0.5.15" 665 711 source = "registry+https://github.com/rust-lang/crates.io-index" 666 712 checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" 713 + dependencies = [ 714 + "crossbeam-utils", 715 + ] 716 + 717 + [[package]] 718 + name = "crossbeam-queue" 719 + version = "0.3.12" 720 + source = "registry+https://github.com/rust-lang/crates.io-index" 721 + checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" 667 722 dependencies = [ 668 723 "crossbeam-utils", 669 724 ] ··· 772 827 checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" 773 828 774 829 [[package]] 830 + name = "der" 831 + version = "0.7.10" 832 + source = "registry+https://github.com/rust-lang/crates.io-index" 833 + checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" 834 + dependencies = [ 835 + "const-oid", 836 + "pem-rfc7468", 837 + "zeroize", 838 + ] 839 + 840 + [[package]] 775 841 name = "deranged" 776 842 version = "0.5.5" 777 843 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 823 889 checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" 824 890 dependencies = [ 825 891 "block-buffer", 892 + "const-oid", 826 893 "crypto-common", 894 + "subtle", 827 895 ] 828 896 829 897 [[package]] ··· 1560 1628 ] 1561 1629 1562 1630 [[package]] 1631 + name = "dotenvy" 1632 + version = "0.15.7" 1633 + source = "registry+https://github.com/rust-lang/crates.io-index" 1634 + checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" 1635 + 1636 + [[package]] 1563 1637 name = "dpi" 1564 1638 version = "0.1.2" 1565 1639 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1587 1661 checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" 1588 1662 1589 1663 [[package]] 1664 + name = "either" 1665 + version = "1.15.0" 1666 + source = "registry+https://github.com/rust-lang/crates.io-index" 1667 + checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 1668 + dependencies = [ 1669 + "serde", 1670 + ] 1671 + 1672 + [[package]] 1590 1673 name = "encoding_rs" 1591 1674 version = "0.8.35" 1592 1675 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1633 1716 ] 1634 1717 1635 1718 [[package]] 1719 + name = "etcetera" 1720 + version = "0.8.0" 1721 + source = "registry+https://github.com/rust-lang/crates.io-index" 1722 + checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" 1723 + dependencies = [ 1724 + "cfg-if", 1725 + "home", 1726 + "windows-sys 0.48.0", 1727 + ] 1728 + 1729 + [[package]] 1636 1730 name = "euclid" 1637 1731 version = "0.22.13" 1638 1732 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1643 1737 ] 1644 1738 1645 1739 [[package]] 1740 + name = "event-listener" 1741 + version = "5.4.1" 1742 + source = "registry+https://github.com/rust-lang/crates.io-index" 1743 + checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" 1744 + dependencies = [ 1745 + "concurrent-queue", 1746 + "parking", 1747 + "pin-project-lite", 1748 + ] 1749 + 1750 + [[package]] 1646 1751 name = "fastrand" 1647 1752 version = "2.3.0" 1648 1753 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1684 1789 ] 1685 1790 1686 1791 [[package]] 1792 + name = "flume" 1793 + version = "0.11.1" 1794 + source = "registry+https://github.com/rust-lang/crates.io-index" 1795 + checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" 1796 + dependencies = [ 1797 + "futures-core", 1798 + "futures-sink", 1799 + "spin", 1800 + ] 1801 + 1802 + [[package]] 1687 1803 name = "fnv" 1688 1804 version = "1.0.7" 1689 1805 source = "registry+https://github.com/rust-lang/crates.io-index" 1690 1806 checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 1807 + 1808 + [[package]] 1809 + name = "foldhash" 1810 + version = "0.1.5" 1811 + source = "registry+https://github.com/rust-lang/crates.io-index" 1812 + checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" 1691 1813 1692 1814 [[package]] 1693 1815 name = "foldhash" ··· 1796 1918 "futures-core", 1797 1919 "futures-task", 1798 1920 "futures-util", 1921 + ] 1922 + 1923 + [[package]] 1924 + name = "futures-intrusive" 1925 + version = "0.5.0" 1926 + source = "registry+https://github.com/rust-lang/crates.io-index" 1927 + checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" 1928 + dependencies = [ 1929 + "futures-core", 1930 + "lock_api", 1931 + "parking_lot", 1799 1932 ] 1800 1933 1801 1934 [[package]] ··· 2250 2383 2251 2384 [[package]] 2252 2385 name = "hashbrown" 2386 + version = "0.15.5" 2387 + source = "registry+https://github.com/rust-lang/crates.io-index" 2388 + checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" 2389 + dependencies = [ 2390 + "allocator-api2", 2391 + "equivalent", 2392 + "foldhash 0.1.5", 2393 + ] 2394 + 2395 + [[package]] 2396 + name = "hashbrown" 2253 2397 version = "0.16.1" 2254 2398 source = "registry+https://github.com/rust-lang/crates.io-index" 2255 2399 checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" 2256 2400 dependencies = [ 2257 2401 "allocator-api2", 2258 2402 "equivalent", 2259 - "foldhash", 2403 + "foldhash 0.2.0", 2404 + ] 2405 + 2406 + [[package]] 2407 + name = "hashlink" 2408 + version = "0.10.0" 2409 + source = "registry+https://github.com/rust-lang/crates.io-index" 2410 + checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" 2411 + dependencies = [ 2412 + "hashbrown 0.15.5", 2260 2413 ] 2261 2414 2262 2415 [[package]] ··· 2296 2449 checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 2297 2450 2298 2451 [[package]] 2452 + name = "hex" 2453 + version = "0.4.3" 2454 + source = "registry+https://github.com/rust-lang/crates.io-index" 2455 + checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 2456 + 2457 + [[package]] 2458 + name = "hkdf" 2459 + version = "0.12.4" 2460 + source = "registry+https://github.com/rust-lang/crates.io-index" 2461 + checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" 2462 + dependencies = [ 2463 + "hmac", 2464 + ] 2465 + 2466 + [[package]] 2467 + name = "hmac" 2468 + version = "0.12.1" 2469 + source = "registry+https://github.com/rust-lang/crates.io-index" 2470 + checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" 2471 + dependencies = [ 2472 + "digest", 2473 + ] 2474 + 2475 + [[package]] 2476 + name = "home" 2477 + version = "0.5.12" 2478 + source = "registry+https://github.com/rust-lang/crates.io-index" 2479 + checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" 2480 + dependencies = [ 2481 + "windows-sys 0.61.2", 2482 + ] 2483 + 2484 + [[package]] 2299 2485 name = "html5ever" 2300 2486 version = "0.29.1" 2301 2487 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2695 2881 version = "1.5.0" 2696 2882 source = "registry+https://github.com/rust-lang/crates.io-index" 2697 2883 checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 2884 + dependencies = [ 2885 + "spin", 2886 + ] 2698 2887 2699 2888 [[package]] 2700 2889 name = "libappindicator" ··· 2747 2936 ] 2748 2937 2749 2938 [[package]] 2939 + name = "libm" 2940 + version = "0.2.16" 2941 + source = "registry+https://github.com/rust-lang/crates.io-index" 2942 + checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" 2943 + 2944 + [[package]] 2750 2945 name = "libredox" 2751 2946 version = "0.1.12" 2752 2947 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2754 2949 dependencies = [ 2755 2950 "bitflags 2.10.0", 2756 2951 "libc", 2952 + "redox_syscall 0.7.0", 2953 + ] 2954 + 2955 + [[package]] 2956 + name = "libsqlite3-sys" 2957 + version = "0.30.1" 2958 + source = "registry+https://github.com/rust-lang/crates.io-index" 2959 + checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" 2960 + dependencies = [ 2961 + "pkg-config", 2962 + "vcpkg", 2757 2963 ] 2758 2964 2759 2965 [[package]] ··· 2942 3148 checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" 2943 3149 2944 3150 [[package]] 3151 + name = "md-5" 3152 + version = "0.10.6" 3153 + source = "registry+https://github.com/rust-lang/crates.io-index" 3154 + checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" 3155 + dependencies = [ 3156 + "cfg-if", 3157 + "digest", 3158 + ] 3159 + 3160 + [[package]] 2945 3161 name = "memchr" 2946 3162 version = "2.8.0" 2947 3163 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3109 3325 checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" 3110 3326 3111 3327 [[package]] 3328 + name = "num-bigint-dig" 3329 + version = "0.8.6" 3330 + source = "registry+https://github.com/rust-lang/crates.io-index" 3331 + checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" 3332 + dependencies = [ 3333 + "lazy_static", 3334 + "libm", 3335 + "num-integer", 3336 + "num-iter", 3337 + "num-traits", 3338 + "rand 0.8.5", 3339 + "smallvec", 3340 + "zeroize", 3341 + ] 3342 + 3343 + [[package]] 3112 3344 name = "num-conv" 3113 3345 version = "0.2.0" 3114 3346 source = "registry+https://github.com/rust-lang/crates.io-index" 3115 3347 checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" 3116 3348 3117 3349 [[package]] 3350 + name = "num-integer" 3351 + version = "0.1.46" 3352 + source = "registry+https://github.com/rust-lang/crates.io-index" 3353 + checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 3354 + dependencies = [ 3355 + "num-traits", 3356 + ] 3357 + 3358 + [[package]] 3359 + name = "num-iter" 3360 + version = "0.1.45" 3361 + source = "registry+https://github.com/rust-lang/crates.io-index" 3362 + checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" 3363 + dependencies = [ 3364 + "autocfg", 3365 + "num-integer", 3366 + "num-traits", 3367 + ] 3368 + 3369 + [[package]] 3118 3370 name = "num-traits" 3119 3371 version = "0.2.19" 3120 3372 source = "registry+https://github.com/rust-lang/crates.io-index" 3121 3373 checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 3122 3374 dependencies = [ 3123 3375 "autocfg", 3376 + "libm", 3124 3377 ] 3125 3378 3126 3379 [[package]] ··· 3342 3595 ] 3343 3596 3344 3597 [[package]] 3598 + name = "parking" 3599 + version = "2.2.1" 3600 + source = "registry+https://github.com/rust-lang/crates.io-index" 3601 + checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" 3602 + 3603 + [[package]] 3345 3604 name = "parking_lot" 3346 3605 version = "0.12.5" 3347 3606 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3359 3618 dependencies = [ 3360 3619 "cfg-if", 3361 3620 "libc", 3362 - "redox_syscall", 3621 + "redox_syscall 0.5.18", 3363 3622 "smallvec", 3364 3623 "windows-link 0.2.1", 3365 3624 ] 3366 3625 3367 3626 [[package]] 3627 + name = "pem-rfc7468" 3628 + version = "0.7.0" 3629 + source = "registry+https://github.com/rust-lang/crates.io-index" 3630 + checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" 3631 + dependencies = [ 3632 + "base64ct", 3633 + ] 3634 + 3635 + [[package]] 3368 3636 name = "percent-encoding" 3369 3637 version = "2.3.2" 3370 3638 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3523 3791 checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 3524 3792 3525 3793 [[package]] 3794 + name = "pkcs1" 3795 + version = "0.7.5" 3796 + source = "registry+https://github.com/rust-lang/crates.io-index" 3797 + checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" 3798 + dependencies = [ 3799 + "der", 3800 + "pkcs8", 3801 + "spki", 3802 + ] 3803 + 3804 + [[package]] 3805 + name = "pkcs8" 3806 + version = "0.10.2" 3807 + source = "registry+https://github.com/rust-lang/crates.io-index" 3808 + checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" 3809 + dependencies = [ 3810 + "der", 3811 + "spki", 3812 + ] 3813 + 3814 + [[package]] 3526 3815 name = "pkg-config" 3527 3816 version = "0.3.32" 3528 3817 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3875 4164 ] 3876 4165 3877 4166 [[package]] 4167 + name = "redox_syscall" 4168 + version = "0.7.0" 4169 + source = "registry+https://github.com/rust-lang/crates.io-index" 4170 + checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" 4171 + dependencies = [ 4172 + "bitflags 2.10.0", 4173 + ] 4174 + 4175 + [[package]] 3878 4176 name = "redox_users" 3879 4177 version = "0.5.2" 3880 4178 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 3985 4283 ] 3986 4284 3987 4285 [[package]] 4286 + name = "rsa" 4287 + version = "0.9.10" 4288 + source = "registry+https://github.com/rust-lang/crates.io-index" 4289 + checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" 4290 + dependencies = [ 4291 + "const-oid", 4292 + "digest", 4293 + "num-bigint-dig", 4294 + "num-integer", 4295 + "num-traits", 4296 + "pkcs1", 4297 + "pkcs8", 4298 + "rand_core 0.6.4", 4299 + "signature", 4300 + "spki", 4301 + "subtle", 4302 + "zeroize", 4303 + ] 4304 + 4305 + [[package]] 3988 4306 name = "rustc-hash" 3989 4307 version = "1.1.0" 3990 4308 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4321 4639 ] 4322 4640 4323 4641 [[package]] 4642 + name = "signature" 4643 + version = "2.2.0" 4644 + source = "registry+https://github.com/rust-lang/crates.io-index" 4645 + checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" 4646 + dependencies = [ 4647 + "digest", 4648 + "rand_core 0.6.4", 4649 + ] 4650 + 4651 + [[package]] 4324 4652 name = "simd-adler32" 4325 4653 version = "0.3.8" 4326 4654 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 4388 4716 version = "1.15.1" 4389 4717 source = "registry+https://github.com/rust-lang/crates.io-index" 4390 4718 checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" 4719 + dependencies = [ 4720 + "serde", 4721 + ] 4391 4722 4392 4723 [[package]] 4393 4724 name = "socket2" ··· 4430 4761 version = "0.9.8" 4431 4762 source = "registry+https://github.com/rust-lang/crates.io-index" 4432 4763 checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" 4764 + dependencies = [ 4765 + "lock_api", 4766 + ] 4767 + 4768 + [[package]] 4769 + name = "spki" 4770 + version = "0.7.3" 4771 + source = "registry+https://github.com/rust-lang/crates.io-index" 4772 + checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" 4773 + dependencies = [ 4774 + "base64ct", 4775 + "der", 4776 + ] 4777 + 4778 + [[package]] 4779 + name = "sqlx" 4780 + version = "0.8.6" 4781 + source = "registry+https://github.com/rust-lang/crates.io-index" 4782 + checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" 4783 + dependencies = [ 4784 + "sqlx-core", 4785 + "sqlx-macros", 4786 + "sqlx-mysql", 4787 + "sqlx-postgres", 4788 + "sqlx-sqlite", 4789 + ] 4790 + 4791 + [[package]] 4792 + name = "sqlx-core" 4793 + version = "0.8.6" 4794 + source = "registry+https://github.com/rust-lang/crates.io-index" 4795 + checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" 4796 + dependencies = [ 4797 + "base64", 4798 + "bytes", 4799 + "crc", 4800 + "crossbeam-queue", 4801 + "either", 4802 + "event-listener", 4803 + "futures-core", 4804 + "futures-intrusive", 4805 + "futures-io", 4806 + "futures-util", 4807 + "hashbrown 0.15.5", 4808 + "hashlink", 4809 + "indexmap", 4810 + "log", 4811 + "memchr", 4812 + "once_cell", 4813 + "percent-encoding", 4814 + "serde", 4815 + "serde_json", 4816 + "sha2", 4817 + "smallvec", 4818 + "thiserror 2.0.18", 4819 + "tokio", 4820 + "tokio-stream", 4821 + "tracing", 4822 + "url", 4823 + ] 4824 + 4825 + [[package]] 4826 + name = "sqlx-macros" 4827 + version = "0.8.6" 4828 + source = "registry+https://github.com/rust-lang/crates.io-index" 4829 + checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" 4830 + dependencies = [ 4831 + "proc-macro2", 4832 + "quote", 4833 + "sqlx-core", 4834 + "sqlx-macros-core", 4835 + "syn 2.0.114", 4836 + ] 4837 + 4838 + [[package]] 4839 + name = "sqlx-macros-core" 4840 + version = "0.8.6" 4841 + source = "registry+https://github.com/rust-lang/crates.io-index" 4842 + checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" 4843 + dependencies = [ 4844 + "dotenvy", 4845 + "either", 4846 + "heck 0.5.0", 4847 + "hex", 4848 + "once_cell", 4849 + "proc-macro2", 4850 + "quote", 4851 + "serde", 4852 + "serde_json", 4853 + "sha2", 4854 + "sqlx-core", 4855 + "sqlx-mysql", 4856 + "sqlx-postgres", 4857 + "sqlx-sqlite", 4858 + "syn 2.0.114", 4859 + "tokio", 4860 + "url", 4861 + ] 4862 + 4863 + [[package]] 4864 + name = "sqlx-mysql" 4865 + version = "0.8.6" 4866 + source = "registry+https://github.com/rust-lang/crates.io-index" 4867 + checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" 4868 + dependencies = [ 4869 + "atoi", 4870 + "base64", 4871 + "bitflags 2.10.0", 4872 + "byteorder", 4873 + "bytes", 4874 + "crc", 4875 + "digest", 4876 + "dotenvy", 4877 + "either", 4878 + "futures-channel", 4879 + "futures-core", 4880 + "futures-io", 4881 + "futures-util", 4882 + "generic-array", 4883 + "hex", 4884 + "hkdf", 4885 + "hmac", 4886 + "itoa", 4887 + "log", 4888 + "md-5", 4889 + "memchr", 4890 + "once_cell", 4891 + "percent-encoding", 4892 + "rand 0.8.5", 4893 + "rsa", 4894 + "serde", 4895 + "sha1", 4896 + "sha2", 4897 + "smallvec", 4898 + "sqlx-core", 4899 + "stringprep", 4900 + "thiserror 2.0.18", 4901 + "tracing", 4902 + "whoami", 4903 + ] 4904 + 4905 + [[package]] 4906 + name = "sqlx-postgres" 4907 + version = "0.8.6" 4908 + source = "registry+https://github.com/rust-lang/crates.io-index" 4909 + checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" 4910 + dependencies = [ 4911 + "atoi", 4912 + "base64", 4913 + "bitflags 2.10.0", 4914 + "byteorder", 4915 + "crc", 4916 + "dotenvy", 4917 + "etcetera", 4918 + "futures-channel", 4919 + "futures-core", 4920 + "futures-util", 4921 + "hex", 4922 + "hkdf", 4923 + "hmac", 4924 + "home", 4925 + "itoa", 4926 + "log", 4927 + "md-5", 4928 + "memchr", 4929 + "once_cell", 4930 + "rand 0.8.5", 4931 + "serde", 4932 + "serde_json", 4933 + "sha2", 4934 + "smallvec", 4935 + "sqlx-core", 4936 + "stringprep", 4937 + "thiserror 2.0.18", 4938 + "tracing", 4939 + "whoami", 4940 + ] 4941 + 4942 + [[package]] 4943 + name = "sqlx-sqlite" 4944 + version = "0.8.6" 4945 + source = "registry+https://github.com/rust-lang/crates.io-index" 4946 + checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" 4947 + dependencies = [ 4948 + "atoi", 4949 + "flume", 4950 + "futures-channel", 4951 + "futures-core", 4952 + "futures-executor", 4953 + "futures-intrusive", 4954 + "futures-util", 4955 + "libsqlite3-sys", 4956 + "log", 4957 + "percent-encoding", 4958 + "serde", 4959 + "serde_urlencoded", 4960 + "sqlx-core", 4961 + "thiserror 2.0.18", 4962 + "tracing", 4963 + "url", 4964 + ] 4433 4965 4434 4966 [[package]] 4435 4967 name = "stable_deref_trait" ··· 4460 4992 "phf_shared 0.11.3", 4461 4993 "proc-macro2", 4462 4994 "quote", 4995 + ] 4996 + 4997 + [[package]] 4998 + name = "stringprep" 4999 + version = "0.1.5" 5000 + source = "registry+https://github.com/rust-lang/crates.io-index" 5001 + checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" 5002 + dependencies = [ 5003 + "unicode-bidi", 5004 + "unicode-normalization", 5005 + "unicode-properties", 4463 5006 ] 4464 5007 4465 5008 [[package]] ··· 5121 5664 checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" 5122 5665 5123 5666 [[package]] 5667 + name = "unicode-bidi" 5668 + version = "0.3.18" 5669 + source = "registry+https://github.com/rust-lang/crates.io-index" 5670 + checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" 5671 + 5672 + [[package]] 5124 5673 name = "unicode-ident" 5125 5674 version = "1.0.22" 5126 5675 source = "registry+https://github.com/rust-lang/crates.io-index" 5127 5676 checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" 5677 + 5678 + [[package]] 5679 + name = "unicode-normalization" 5680 + version = "0.1.25" 5681 + source = "registry+https://github.com/rust-lang/crates.io-index" 5682 + checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" 5683 + dependencies = [ 5684 + "tinyvec", 5685 + ] 5686 + 5687 + [[package]] 5688 + name = "unicode-properties" 5689 + version = "0.1.4" 5690 + source = "registry+https://github.com/rust-lang/crates.io-index" 5691 + checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" 5128 5692 5129 5693 [[package]] 5130 5694 name = "unicode-segmentation" ··· 5259 5823 ] 5260 5824 5261 5825 [[package]] 5826 + name = "wasite" 5827 + version = "0.1.0" 5828 + source = "registry+https://github.com/rust-lang/crates.io-index" 5829 + checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" 5830 + 5831 + [[package]] 5262 5832 name = "wasm-bindgen" 5263 5833 version = "0.2.108" 5264 5834 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 5456 6026 ] 5457 6027 5458 6028 [[package]] 6029 + name = "whoami" 6030 + version = "1.6.1" 6031 + source = "registry+https://github.com/rust-lang/crates.io-index" 6032 + checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" 6033 + dependencies = [ 6034 + "libredox", 6035 + "wasite", 6036 + ] 6037 + 6038 + [[package]] 5459 6039 name = "winapi" 5460 6040 version = "0.3.9" 5461 6041 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 5647 6227 5648 6228 [[package]] 5649 6229 name = "windows-sys" 6230 + version = "0.48.0" 6231 + source = "registry+https://github.com/rust-lang/crates.io-index" 6232 + checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 6233 + dependencies = [ 6234 + "windows-targets 0.48.5", 6235 + ] 6236 + 6237 + [[package]] 6238 + name = "windows-sys" 5650 6239 version = "0.52.0" 5651 6240 source = "registry+https://github.com/rust-lang/crates.io-index" 5652 6241 checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" ··· 5698 6287 5699 6288 [[package]] 5700 6289 name = "windows-targets" 6290 + version = "0.48.5" 6291 + source = "registry+https://github.com/rust-lang/crates.io-index" 6292 + checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 6293 + dependencies = [ 6294 + "windows_aarch64_gnullvm 0.48.5", 6295 + "windows_aarch64_msvc 0.48.5", 6296 + "windows_i686_gnu 0.48.5", 6297 + "windows_i686_msvc 0.48.5", 6298 + "windows_x86_64_gnu 0.48.5", 6299 + "windows_x86_64_gnullvm 0.48.5", 6300 + "windows_x86_64_msvc 0.48.5", 6301 + ] 6302 + 6303 + [[package]] 6304 + name = "windows-targets" 5701 6305 version = "0.52.6" 5702 6306 source = "registry+https://github.com/rust-lang/crates.io-index" 5703 6307 checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" ··· 5755 6359 5756 6360 [[package]] 5757 6361 name = "windows_aarch64_gnullvm" 6362 + version = "0.48.5" 6363 + source = "registry+https://github.com/rust-lang/crates.io-index" 6364 + checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 6365 + 6366 + [[package]] 6367 + name = "windows_aarch64_gnullvm" 5758 6368 version = "0.52.6" 5759 6369 source = "registry+https://github.com/rust-lang/crates.io-index" 5760 6370 checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" ··· 5770 6380 version = "0.42.2" 5771 6381 source = "registry+https://github.com/rust-lang/crates.io-index" 5772 6382 checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" 6383 + 6384 + [[package]] 6385 + name = "windows_aarch64_msvc" 6386 + version = "0.48.5" 6387 + source = "registry+https://github.com/rust-lang/crates.io-index" 6388 + checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 5773 6389 5774 6390 [[package]] 5775 6391 name = "windows_aarch64_msvc" ··· 5791 6407 5792 6408 [[package]] 5793 6409 name = "windows_i686_gnu" 6410 + version = "0.48.5" 6411 + source = "registry+https://github.com/rust-lang/crates.io-index" 6412 + checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 6413 + 6414 + [[package]] 6415 + name = "windows_i686_gnu" 5794 6416 version = "0.52.6" 5795 6417 source = "registry+https://github.com/rust-lang/crates.io-index" 5796 6418 checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" ··· 5821 6443 5822 6444 [[package]] 5823 6445 name = "windows_i686_msvc" 6446 + version = "0.48.5" 6447 + source = "registry+https://github.com/rust-lang/crates.io-index" 6448 + checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 6449 + 6450 + [[package]] 6451 + name = "windows_i686_msvc" 5824 6452 version = "0.52.6" 5825 6453 source = "registry+https://github.com/rust-lang/crates.io-index" 5826 6454 checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" ··· 5839 6467 5840 6468 [[package]] 5841 6469 name = "windows_x86_64_gnu" 6470 + version = "0.48.5" 6471 + source = "registry+https://github.com/rust-lang/crates.io-index" 6472 + checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 6473 + 6474 + [[package]] 6475 + name = "windows_x86_64_gnu" 5842 6476 version = "0.52.6" 5843 6477 source = "registry+https://github.com/rust-lang/crates.io-index" 5844 6478 checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" ··· 5857 6491 5858 6492 [[package]] 5859 6493 name = "windows_x86_64_gnullvm" 6494 + version = "0.48.5" 6495 + source = "registry+https://github.com/rust-lang/crates.io-index" 6496 + checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 6497 + 6498 + [[package]] 6499 + name = "windows_x86_64_gnullvm" 5860 6500 version = "0.52.6" 5861 6501 source = "registry+https://github.com/rust-lang/crates.io-index" 5862 6502 checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" ··· 5872 6512 version = "0.42.2" 5873 6513 source = "registry+https://github.com/rust-lang/crates.io-index" 5874 6514 checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" 6515 + 6516 + [[package]] 6517 + name = "windows_x86_64_msvc" 6518 + version = "0.48.5" 6519 + source = "registry+https://github.com/rust-lang/crates.io-index" 6520 + checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 5875 6521 5876 6522 [[package]] 5877 6523 name = "windows_x86_64_msvc"
+2 -1
Cargo.toml
··· 8 8 9 9 [dependencies] 10 10 dioxus = { version = "0.7.1", features = ["router", "fullstack"] } 11 + sqlx = { version = "0.8.6", features = ["runtime-tokio", "postgres"], optional = true } 11 12 12 13 [features] 13 14 default = ["web"] 14 15 web = ["dioxus/web"] 15 16 desktop = ["dioxus/desktop"] 16 17 mobile = ["dioxus/mobile"] 17 - server = ["dioxus/server"] 18 + server = ["dioxus/server", "dep:sqlx"]
+10 -48
Justfile
··· 5 5 default: dev 6 6 7 7 [group: "dev"] 8 - fix: fmt (lint "fix") 8 + fix: fmt 9 9 10 10 export CONCURRENTLY_KILL_OTHERS := "true" 11 11 export CONCURRENTLY_PAD_PREFIX := "true" ··· 19 19 shadow_database_name := if SHADOW_DATABASE_URL != "" { file_stem(SHADOW_DATABASE_URL) } else { "" } 20 20 21 21 [group: "run"] 22 - dev: up squirrel 23 - npx concurrently --names "sveltekit,migrate,server" \ 24 - "cd app && npx vite dev --host" \ 25 - "npx graphile-migrate watch" \ 26 - "cd server && gleam run" 27 - 28 - [working-directory: "server"] 29 - server: up squirrel 30 - gleam run 22 + dev: up 23 + npx concurrently --names "app,migrate" \ 24 + "dx run" \ 25 + "npx graphile-migrate watch" 31 26 32 27 [group: "dev"] 33 28 init: ··· 36 31 cp -n .env.example .env.local 37 32 cd .git/hooks && ln -sf ../../.hooks/* . 38 33 if [ ! -f .env ]; then ln -s .env.local .env; fi 39 - just get 40 34 just up 41 - 42 - [group: "dev"] 43 - get: 44 - cd app && npm install 45 - cd server && gleam deps download 46 - cd api && gleam deps download 47 35 48 36 [group: "docker"] 49 37 up: && migrate ··· 59 47 stop: 60 48 docker compose stop 61 49 62 - [group: "release"] 63 - build: 64 - cd server && gleam build 65 - cd app && npx svelte-kit sync 66 - cd app && npx vite build 67 - 68 50 [group: "dev"] 69 51 clean: 70 - rm -rf app/.svelte-kit app/build app/.eslintcache 52 + cargo clean 71 53 72 54 [group: "dev"] 73 55 check: 74 - cd api && gleam check 75 - cd server && gleam check 76 - cd app && npx svelte-kit sync 77 - cd app && npx svelte-check --tsconfig ./tsconfig.json 78 - 79 - [group: "dev"] 80 - watch: 81 - cd app && npx svelte-kit sync 82 - cd app && npx svelte-check --tsconfig ./tsconfig.json --watch 83 - 84 - [group: "dev"] 85 - lint mode="check": 86 - cd app && npx eslint . {{ if mode == "fix" { "--fix" } else { "--cache" } }} 56 + dx check 87 57 88 58 [group: "dev"] 89 59 fmt: 90 - cd api && gleam format 91 - cd server && gleam format 92 - cd app && npx prettier --write . --cache 60 + dx fmt 61 + cargo fmt 93 62 94 63 [group: "dev"] 95 64 test: 96 - cd api && gleam test 97 - cd server && gleam test 98 - cd app && npm test 65 + cargo test 99 66 100 67 [group: "database"] 101 68 migrate: 102 69 npx graphile-migrate migrate --forceActions 103 - 104 - [group: "database"] 105 - [working-directory: "server"] 106 - squirrel: up 107 - gleam run -m squirrel 108 70 109 71 [group: "database"] 110 72 migration-dev:
+1 -9
generated/schema.sql
··· 170 170 CREATE TABLE public.citizens ( 171 171 species_id text NOT NULL, 172 172 name text NOT NULL, 173 - id bigint NOT NULL, 174 173 home_tile_id bigint, 174 + id bigint NOT NULL, 175 175 CONSTRAINT citizens_name_check CHECK (((0 < length(name)) AND (length(name) < 64))) 176 176 ); 177 177 ··· 705 705 706 706 ALTER TABLE ONLY public.cards 707 707 ADD CONSTRAINT cards_card_type_id_fkey FOREIGN KEY (card_type_id) REFERENCES public.card_types(id) ON UPDATE CASCADE ON DELETE RESTRICT; 708 - 709 - 710 - -- 711 - -- Name: citizens citizens_home_tile_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - 712 - -- 713 - 714 - ALTER TABLE ONLY public.citizens 715 - ADD CONSTRAINT citizens_home_tile_id_fkey FOREIGN KEY (home_tile_id) REFERENCES public.tiles(id) ON UPDATE CASCADE ON DELETE SET NULL; 716 708 717 709 718 710 --
+7
src/api.rs
··· 1 + use dioxus::prelude::*; 2 + 3 + /// Echo the user input on the server. 4 + #[post("/api/echo")] 5 + pub async fn echo_server(input: String) -> Result<String, ServerFnError> { 6 + Ok(input) 7 + }
+113
src/app.rs
··· 1 + use dioxus::prelude::*; 2 + 3 + use crate::api::echo_server; 4 + 5 + const FAVICON: Asset = asset!("/assets/favicon.ico"); 6 + const MAIN_CSS: Asset = asset!("/assets/main.css"); 7 + const HEADER_SVG: Asset = asset!("/assets/header.svg"); 8 + 9 + #[derive(Debug, Clone, Routable, PartialEq)] 10 + #[rustfmt::skip] 11 + enum Route { 12 + #[layout(Navbar)] 13 + #[route("/")] 14 + Home {}, 15 + #[route("/blog/:id")] 16 + Blog { id: i32 }, 17 + } 18 + 19 + #[component] 20 + pub fn App() -> Element { 21 + rsx! { 22 + document::Link { rel: "icon", href: FAVICON } 23 + document::Link { rel: "stylesheet", href: MAIN_CSS } 24 + Router::<Route> {} 25 + } 26 + } 27 + 28 + #[component] 29 + pub fn Hero() -> Element { 30 + rsx! { 31 + div { id: "hero", 32 + img { src: HEADER_SVG, id: "header" } 33 + div { id: "links", 34 + a { href: "https://dioxuslabs.com/learn/0.7/", "📚 Learn Dioxus" } 35 + a { href: "https://dioxuslabs.com/awesome", "🚀 Awesome Dioxus" } 36 + a { href: "https://github.com/dioxus-community/", "📡 Community Libraries" } 37 + a { href: "https://github.com/DioxusLabs/sdk", "⚙️ Dioxus Development Kit" } 38 + a { href: "https://marketplace.visualstudio.com/items?itemName=DioxusLabs.dioxus", 39 + "💫 VSCode Extension" 40 + } 41 + a { href: "https://discord.gg/XgGxMSkvUM", "👋 Community Discord" } 42 + } 43 + } 44 + } 45 + } 46 + 47 + /// Home page 48 + #[component] 49 + fn Home() -> Element { 50 + rsx! { 51 + Hero {} 52 + Echo {} 53 + } 54 + } 55 + 56 + /// Blog page 57 + #[component] 58 + pub fn Blog(id: i32) -> Element { 59 + rsx! { 60 + div { id: "blog", 61 + 62 + // Content 63 + h1 { "This is blog #{id}!" } 64 + p { 65 + "In blog #{id}, we show how the Dioxus router works and how URL parameters can be passed as props to our route components." 66 + } 67 + 68 + // Navigation links 69 + Link { to: Route::Blog { id: id - 1 }, "Previous" } 70 + span { " <---> " } 71 + Link { to: Route::Blog { id: id + 1 }, "Next" } 72 + } 73 + } 74 + } 75 + 76 + /// Shared navbar component. 77 + #[component] 78 + fn Navbar() -> Element { 79 + rsx! { 80 + div { id: "navbar", 81 + Link { to: Route::Home {}, "Home" } 82 + Link { to: Route::Blog { id: 1 }, "Blog" } 83 + } 84 + 85 + Outlet::<Route> {} 86 + } 87 + } 88 + 89 + /// Echo component that demonstrates fullstack server functions. 90 + #[component] 91 + fn Echo() -> Element { 92 + let mut response = use_signal(String::new); 93 + 94 + rsx! { 95 + div { id: "echo", 96 + h4 { "ServerFn Echo" } 97 + input { 98 + placeholder: "Type here to echo...", 99 + oninput: move |event| async move { 100 + let data = echo_server(event.value()).await.unwrap(); 101 + response.set(data); 102 + }, 103 + } 104 + 105 + if !response().is_empty() { 106 + p { 107 + "Server echoed: " 108 + i { "{response}" } 109 + } 110 + } 111 + } 112 + } 113 + }
+18 -125
src/main.rs
··· 1 - use dioxus::prelude::*; 2 - 3 - #[derive(Debug, Clone, Routable, PartialEq)] 4 - #[rustfmt::skip] 5 - enum Route { 6 - #[layout(Navbar)] 7 - #[route("/")] 8 - Home {}, 9 - #[route("/blog/:id")] 10 - Blog { id: i32 }, 11 - } 1 + mod api; 2 + mod app; 12 3 13 - const FAVICON: Asset = asset!("/assets/favicon.ico"); 14 - const MAIN_CSS: Asset = asset!("/assets/main.css"); 15 - const HEADER_SVG: Asset = asset!("/assets/header.svg"); 4 + use crate::app::App; 16 5 17 6 fn main() { 18 - dioxus::launch(App); 19 - } 7 + #[cfg(not(feature = "server"))] 8 + dioxus::fullstack::set_server_url(""); 20 9 21 - #[component] 22 - fn App() -> Element { 23 - rsx! { 24 - document::Link { rel: "icon", href: FAVICON } 25 - document::Link { rel: "stylesheet", href: MAIN_CSS } 26 - Router::<Route> {} 27 - } 28 - } 10 + #[cfg(not(feature = "server"))] 11 + dioxus::launch(App); 29 12 30 - #[component] 31 - pub fn Hero() -> Element { 32 - rsx! { 33 - div { 34 - id: "hero", 35 - img { src: HEADER_SVG, id: "header" } 36 - div { id: "links", 37 - a { href: "https://dioxuslabs.com/learn/0.7/", "📚 Learn Dioxus" } 38 - a { href: "https://dioxuslabs.com/awesome", "🚀 Awesome Dioxus" } 39 - a { href: "https://github.com/dioxus-community/", "📡 Community Libraries" } 40 - a { href: "https://github.com/DioxusLabs/sdk", "⚙️ Dioxus Development Kit" } 41 - a { href: "https://marketplace.visualstudio.com/items?itemName=DioxusLabs.dioxus", "💫 VSCode Extension" } 42 - a { href: "https://discord.gg/XgGxMSkvUM", "👋 Community Discord" } 43 - } 44 - } 45 - } 46 - } 13 + #[cfg(feature = "server")] 14 + dioxus::serve(|| async move { 15 + use dioxus::server::axum::Extension; 47 16 48 - /// Home page 49 - #[component] 50 - fn Home() -> Element { 51 - rsx! { 52 - Hero {} 53 - Echo {} 54 - } 55 - } 17 + let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL is required"); 18 + let pool = sqlx::postgres::PgPoolOptions::new() 19 + .max_connections(10) 20 + .connect(&db_url) 21 + .await?; 56 22 57 - /// Blog page 58 - #[component] 59 - pub fn Blog(id: i32) -> Element { 60 - rsx! { 61 - div { 62 - id: "blog", 63 - 64 - // Content 65 - h1 { "This is blog #{id}!" } 66 - p { "In blog #{id}, we show how the Dioxus router works and how URL parameters can be passed as props to our route components." } 67 - 68 - // Navigation links 69 - Link { 70 - to: Route::Blog { id: id - 1 }, 71 - "Previous" 72 - } 73 - span { " <---> " } 74 - Link { 75 - to: Route::Blog { id: id + 1 }, 76 - "Next" 77 - } 78 - } 79 - } 80 - } 81 - 82 - /// Shared navbar component. 83 - #[component] 84 - fn Navbar() -> Element { 85 - rsx! { 86 - div { 87 - id: "navbar", 88 - Link { 89 - to: Route::Home {}, 90 - "Home" 91 - } 92 - Link { 93 - to: Route::Blog { id: 1 }, 94 - "Blog" 95 - } 96 - } 97 - 98 - Outlet::<Route> {} 99 - } 100 - } 101 - 102 - /// Echo component that demonstrates fullstack server functions. 103 - #[component] 104 - fn Echo() -> Element { 105 - let mut response = use_signal(|| String::new()); 106 - 107 - rsx! { 108 - div { 109 - id: "echo", 110 - h4 { "ServerFn Echo" } 111 - input { 112 - placeholder: "Type here to echo...", 113 - oninput: move |event| async move { 114 - let data = echo_server(event.value()).await.unwrap(); 115 - response.set(data); 116 - }, 117 - } 118 - 119 - if !response().is_empty() { 120 - p { 121 - "Server echoed: " 122 - i { "{response}" } 123 - } 124 - } 125 - } 126 - } 127 - } 128 - 129 - /// Echo the user input on the server. 130 - #[post("/api/echo")] 131 - async fn echo_server(input: String) -> Result<String, ServerFnError> { 132 - Ok(input) 23 + let router = dioxus::server::router(App).layer(Extension(pool)); 24 + Ok(router) 25 + }); 133 26 }