From 8856636649eb7496862b1d4dd3c3dca05aa40e32 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 13:23:50 +0000 Subject: [PATCH 1/8] Strip, Update, & Upgrade --- server/Cargo.lock | 767 ++++++++++++++++++++++++--------- server/Cargo.toml | 17 +- server/src/cache.rs | 4 +- server/src/http.rs | 73 ++-- server/src/models/bulk.rs | 4 +- server/src/models/error.rs | 4 +- server/src/models/profile.rs | 3 +- server/src/routes/address.rs | 52 +-- server/src/routes/name.rs | 44 +- server/src/routes/universal.rs | 48 +-- 10 files changed, 670 insertions(+), 346 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index c60955f..8e4e3ea 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -47,6 +47,27 @@ dependencies = [ "memchr", ] +[[package]] +name = "aide" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0e3b97a21e41ec5c19bfd9b4fc1f7086be104f8b988681230247ffc91cc8ed" +dependencies = [ + "axum 0.7.5", + "bytes", + "cfg-if", + "http 1.1.0", + "indexmap 2.2.6", + "schemars", + "serde", + "serde_json", + "serde_qs", + "thiserror", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -162,6 +183,33 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "aws-lc-rs" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5509d663b2c00ee421bda8d6a24d6c42e15970957de1701b8df9f6fbe5707df1" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5d317212c2a78d86ba6622e969413c38847b62f48111f8b763af3dac2f9840" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + [[package]] name = "axum" version = "0.6.20" @@ -169,13 +217,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +dependencies = [ + "async-trait", + "axum-core 0.4.3", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.1.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -187,11 +264,12 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -203,19 +281,40 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "mime", "rustversion", "tower-layer", "tower-service", ] +[[package]] +name = "axum-core" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "axum-macros" -version = "0.3.8" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdca6a10ecad987bda04e95606ef85a5417dcaac1a78455242d72e031e2b6b62" +checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" dependencies = [ "heck", "proc-macro2", @@ -289,6 +388,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.4.1", + "cexpr", + "clang-sys", + "itertools 0.12.0", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.38", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -509,6 +631,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -527,7 +658,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -567,6 +698,26 @@ dependencies = [ "inout", ] +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "coins-bip32" version = "0.8.7" @@ -877,22 +1028,13 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" -dependencies = [ - "dirs-sys 0.3.7", -] - [[package]] name = "dirs" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys 0.4.1", + "dirs-sys", ] [[package]] @@ -905,17 +1047,6 @@ dependencies = [ "dirs-sys-next", ] -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dirs-sys" version = "0.4.1" @@ -925,7 +1056,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -951,6 +1082,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.16.8" @@ -1030,8 +1167,9 @@ dependencies = [ name = "enstate" version = "1.0.1-2" dependencies = [ + "aide", "anyhow", - "axum", + "axum 0.7.5", "axum-macros", "base32", "bech32 0.10.0-beta", @@ -1058,7 +1196,7 @@ dependencies = [ "redis", "regex", "rustc-hex", - "rustls", + "rustls 0.23.4", "serde", "serde_json", "serde_qs", @@ -1072,8 +1210,6 @@ dependencies = [ "tracing", "tracing-opentelemetry", "tracing-subscriber", - "utoipa", - "utoipa-swagger-ui", ] [[package]] @@ -1130,7 +1266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1399,7 +1535,7 @@ dependencies = [ "futures-timer", "futures-util", "hashers", - "http", + "http 0.2.9", "instant", "jsonwebtoken", "once_cell", @@ -1446,7 +1582,7 @@ checksum = "de34e484e7ae3cab99fbfd013d6c5dc7f9013676a4e0e414d8b12e1213e8b3ba" dependencies = [ "cfg-if", "const-hex", - "dirs 5.0.1", + "dirs", "dunce", "ethers-core", "glob", @@ -1564,6 +1700,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "funty" version = "2.0.0" @@ -1771,8 +1913,8 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", - "indexmap 2.0.2", + "http 0.2.9", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1845,7 +1987,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1859,6 +2001,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -1866,15 +2019,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1899,8 +2069,8 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -1912,6 +2082,24 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "tokio", +] + [[package]] name = "hyper-rustls" version = "0.24.1" @@ -1919,9 +2107,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", - "http", - "hyper", - "rustls", + "http 0.2.9", + "hyper 0.14.27", + "rustls 0.21.7", "tokio", "tokio-rustls", ] @@ -1932,7 +2120,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.27", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -1945,12 +2133,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.27", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.1.0", + "pin-project-lite", + "socket2 0.5.5", + "tokio", +] + [[package]] name = "iana-time-zone" version = "0.1.58" @@ -2047,9 +2251,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.2", @@ -2088,7 +2292,7 @@ checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -2150,7 +2354,7 @@ checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ "base64 0.21.4", "pem", - "ring", + "ring 0.16.20", "serde", "serde_json", "simple_asn1", @@ -2213,6 +2417,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.149" @@ -2231,6 +2441,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.48.5", +] + [[package]] name = "libz-sys" version = "1.1.12" @@ -2312,14 +2532,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "mime_guess" -version = "2.0.4" +name = "minimal-lexical" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" @@ -2338,9 +2554,15 @@ checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "native-tls" version = "0.2.11" @@ -2365,6 +2587,16 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2543,7 +2775,7 @@ checksum = "1a016b8d9495c639af2145ac22387dcb88e44118e45320d9238fbf4e7889abcb" dependencies = [ "async-trait", "futures-core", - "http", + "http 0.2.9", "opentelemetry", "opentelemetry-proto", "opentelemetry-semantic-conventions", @@ -2661,7 +2893,7 @@ dependencies = [ "libc", "redox_syscall 0.4.1", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2675,6 +2907,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "path-slash" version = "0.2.1" @@ -2725,7 +2963,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.2.6", ] [[package]] @@ -3022,9 +3260,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.23.3" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "6472825949c09872e8f2c50bde59fcefc17748b6be5c90fd67cd8b4daca73bfd" dependencies = [ "arc-swap", "async-trait", @@ -3037,7 +3275,7 @@ dependencies = [ "pin-project-lite", "ryu", "sha1_smol", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tokio-retry", "tokio-util", @@ -3144,9 +3382,9 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "hyper-tls", "ipnet", @@ -3157,7 +3395,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.7", "rustls-pemfile", "serde", "serde_json", @@ -3194,12 +3432,27 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -3231,47 +3484,18 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rust-embed" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40" -dependencies = [ - "rust-embed-impl", - "rust-embed-utils", - "walkdir", -] - -[[package]] -name = "rust-embed-impl" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29" -dependencies = [ - "proc-macro2", - "quote", - "rust-embed-utils", - "shellexpand", - "syn 2.0.38", - "walkdir", -] - -[[package]] -name = "rust-embed-utils" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada" -dependencies = [ - "sha2", - "walkdir", -] - [[package]] name = "rustc-demangle" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc-hex" version = "2.1.0" @@ -3297,7 +3521,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3307,11 +3531,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", - "ring", - "rustls-webpki", + "ring 0.16.20", + "rustls-webpki 0.101.6", "sct", ] +[[package]] +name = "rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4d6d8ad9f2492485e13453acbb291dd08f64441b6609c491f1c2cd2c6b4fe1" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.102.2", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "1.0.3" @@ -3321,14 +3560,32 @@ dependencies = [ "base64 0.21.4", ] +[[package]] +name = "rustls-pki-types" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" + [[package]] name = "rustls-webpki" version = "0.101.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", +] + +[[package]] +name = "rustls-webpki" +version = "0.102.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +dependencies = [ + "aws-lc-rs", + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", ] [[package]] @@ -3391,7 +3648,32 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "schemars" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +dependencies = [ + "dyn-clone", + "indexmap 2.2.6", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.109", ] [[package]] @@ -3418,8 +3700,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -3500,6 +3782,17 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "serde_json" version = "1.0.108" @@ -3523,10 +3816,12 @@ dependencies = [ [[package]] name = "serde_qs" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0431a35568651e363364210c91983c1da5eb29404d9f0928b67d4ebcfa7d330c" +checksum = "cd34f36fe4c5ba9654417139a9b3a20d2e1de6012ee678ad14d240c22c78d8d6" dependencies = [ + "axum 0.7.5", + "futures", "percent-encoding", "serde", "thiserror", @@ -3563,7 +3858,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.0.2", + "indexmap 2.2.6", "serde", "serde_json", "serde_with_macros", @@ -3630,13 +3925,10 @@ dependencies = [ ] [[package]] -name = "shellexpand" -version = "2.1.2" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" -dependencies = [ - "dirs 4.0.0", -] +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" @@ -3707,7 +3999,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3730,6 +4022,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -3799,7 +4097,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597e3a746727984cb7ea2487b6a40726cad0dbe86628e7d429aa6b8c4c153db4" dependencies = [ - "dirs 5.0.1", + "dirs", "fs2", "hex", "once_cell", @@ -3841,6 +4139,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -3878,7 +4182,7 @@ dependencies = [ "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3992,7 +4296,7 @@ dependencies = [ "socket2 0.5.5", "tokio-macros", "tracing", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -4043,7 +4347,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.7", "tokio", ] @@ -4066,7 +4370,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.21.7", "tokio", "tokio-rustls", "tungstenite", @@ -4114,7 +4418,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.2.6", "toml_datetime", "winnow", ] @@ -4125,7 +4429,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -4140,13 +4444,13 @@ checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.6.20", "base64 0.21.4", "bytes", "h2", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-timeout", "percent-encoding", "pin-project", @@ -4181,17 +4485,15 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.4.1", "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower-layer", "tower-service", @@ -4315,11 +4617,11 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.9", "httparse", "log", "rand", - "rustls", + "rustls 0.21.7", "sha1", "thiserror", "url", @@ -4344,15 +4646,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.13" @@ -4386,6 +4679,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.0" @@ -4409,47 +4708,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utoipa" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ff05e3bac2c9428f57ade702667753ca3f5cf085e2011fe697de5bfd49aa72d" -dependencies = [ - "indexmap 2.0.2", - "serde", - "serde_json", - "utoipa-gen", -] - -[[package]] -name = "utoipa-gen" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0b6f4667edd64be0e820d6631a60433a269710b6ee89ac39525b872b76d61d" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "regex", - "syn 2.0.38", -] - -[[package]] -name = "utoipa-swagger-ui" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "154517adf0d0b6e22e8e1f385628f14fcaa3db43531dc74303d3edef89d6dfe5" -dependencies = [ - "axum", - "mime_guess", - "regex", - "rust-embed", - "serde", - "serde_json", - "utoipa", - "zip", -] - [[package]] name = "uuid" version = "0.8.2" @@ -4597,6 +4855,18 @@ version = "0.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4634,7 +4904,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -4643,7 +4913,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", ] [[package]] @@ -4652,13 +4931,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -4667,42 +4962,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + [[package]] name = "winnow" version = "0.5.17" @@ -4719,7 +5062,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -4758,9 +5101,9 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" [[package]] name = "zip" diff --git a/server/Cargo.toml b/server/Cargo.toml index baaa20f..b519c87 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,7 +16,7 @@ authors = [ enstate_shared = { path = "../shared" } ethers = "2" -axum = "0.6.18" +axum = "0.7.5" anyhow = "1.0.71" tracing = "0.1.27" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } @@ -26,10 +26,10 @@ serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.28.0", features = ["full", "tracing"] } tokio-util = "0.7.10" futures = "0.3.29" -utoipa = { version = "4.1.0", features = ["axum_extras"] } -utoipa-swagger-ui = { version = "4.0.0", features = ["axum"] } -redis = { version = "0.23.0", features = ["connection-manager", "tokio-comp"] } -tower-http = { version = "0.4.4", features = ["cors", "tracing", "trace"] } +# utoipa = { version = "4.1.0", features = ["axum_extras"] } +# utoipa-swagger-ui = { version = "6.0.0", features = ["axum"] } +redis = { version = "0.25.3", features = ["connection-manager", "tokio-comp"] } +tower-http = { version = "0.5.2", features = ["cors", "tracing", "trace"] } rand = "0.8.5" chrono = "0.4.31" ethers-contract = "2.0.9" @@ -37,12 +37,12 @@ ethers-core = "2.0.9" hex = "0.4.3" thiserror = "1.0.48" regex = "1.9.5" -rustls = "0.21.7" +rustls = "0.23" bs58 = "0.5.0" sha2 = "0.10.7" digest = "0.10.7" hex-literal = "0.4.1" -axum-macros = "0.3.8" +axum-macros = "0.4.1" lazy_static = "1.4.0" base32 = "0.4.0" crc16 = "0.4.0" @@ -52,9 +52,10 @@ serde_with = "3.3.0" bech32 = "0.10.0-alpha" crc32fast = "1.3.2" ciborium = "0.2.1" -serde_qs = "0.12.0" +serde_qs = "0.13.0" tokio-stream = "0.1.14" opentelemetry = "0.22.0" opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] } opentelemetry-otlp = "0.15.0" tracing-opentelemetry = "0.23.0" +aide = { version = "0.13.4", features = ["axum", "scalar"] } diff --git a/server/src/cache.rs b/server/src/cache.rs index f529da3..0a54cf9 100644 --- a/server/src/cache.rs +++ b/server/src/cache.rs @@ -35,9 +35,7 @@ impl CacheLayer for Redis { .set_ex( key, value, - expires - .try_into() - .map_err(|x: TryFromIntError| CacheError::Other(x.to_string()))?, + expires.into(), ) .await; diff --git a/server/src/http.rs b/server/src/http.rs index a7848b7..3c8f048 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -3,12 +3,13 @@ use std::{net::SocketAddr, sync::Arc}; use axum::body::HttpBody; use axum::routing::MethodRouter; use axum::{routing::get, Router}; +use tokio::net::TcpListener; use tokio_util::sync::CancellationToken; use tower_http::cors::CorsLayer; use tower_http::trace::TraceLayer; use tracing::info; -use utoipa::OpenApi; -use utoipa_swagger_ui::SwaggerUi; +// use utoipa::OpenApi; +// use utoipa_swagger_ui::SwaggerUi; use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::error::ErrorResponse; @@ -16,12 +17,12 @@ use crate::models::profile::ENSProfile; use crate::routes; use crate::state::AppState; -#[derive(OpenApi)] -#[openapi( - paths(routes::address::get, routes::name::get, routes::universal::get), - components(schemas(ENSProfile, ListResponse>, ErrorResponse)) -)] -pub struct ApiDoc; +// #[derive(OpenApi)] +// #[openapi( +// paths(routes::address::get, routes::name::get, routes::universal::get), +// components(schemas(ENSProfile, ListResponse>, ErrorResponse)) +// )] +// pub struct ApiDoc; pub struct App { router: Router, @@ -35,11 +36,14 @@ impl App { ) -> Result<(), anyhow::Error> { let addr = SocketAddr::from(([0, 0, 0, 0], port)); - let server = axum::Server::try_bind(&addr)? - .serve(self.router.into_make_service()) - .with_graceful_shutdown(async { - shutdown_signal.cancelled().await; - }); + let listener = TcpListener::bind(&addr).await?; + + async fn await_shutdown(shutdown_signal: CancellationToken) { + shutdown_signal.cancelled().await; + } + + let server = axum::serve(listener, self.router.into_make_service()) + .with_graceful_shutdown(await_shutdown(shutdown_signal)); info!("Listening HTTP on {}", addr); @@ -53,19 +57,19 @@ impl App { pub fn setup(state: AppState) -> App { let router = Router::new() - .merge(SwaggerUi::new("/docs").url("/docs/openapi.json", ApiDoc::openapi())) + // .merge(SwaggerUi::new("/docs").url("/docs/openapi.json", ApiDoc::openapi())) .route("/", get(routes::root::get)) - .directory_route("/a/:address", get(routes::address::get)) - .directory_route("/n/:name", get(routes::name::get)) - .directory_route("/u/:name_or_address", get(routes::universal::get)) - .directory_route("/i/:name_or_address", get(routes::image::get)) - .directory_route("/h/:name_or_address", get(routes::header::get)) - .directory_route("/bulk/a", get(routes::address::get_bulk)) - .directory_route("/bulk/n", get(routes::name::get_bulk)) - .directory_route("/bulk/u", get(routes::universal::get_bulk)) - .directory_route("/sse/a", get(routes::address::get_bulk_sse)) - .directory_route("/sse/n", get(routes::name::get_bulk_sse)) - .directory_route("/sse/u", get(routes::universal::get_bulk_sse)) + .route("/a/:address", get(routes::address::get)) + .route("/n/:name", get(routes::name::get)) + .route("/u/:name_or_address", get(routes::universal::get)) + .route("/i/:name_or_address", get(routes::image::get)) + .route("/h/:name_or_address", get(routes::header::get)) + .route("/bulk/a", get(routes::address::get_bulk)) + .route("/bulk/n", get(routes::name::get_bulk)) + .route("/bulk/u", get(routes::universal::get_bulk)) + .route("/sse/a", get(routes::address::get_bulk_sse)) + .route("/sse/n", get(routes::name::get_bulk_sse)) + .route("/sse/u", get(routes::universal::get_bulk_sse)) .fallback(routes::four_oh_four::handler) .layer(CorsLayer::permissive()) .layer(TraceLayer::new_for_http()) @@ -73,22 +77,3 @@ pub fn setup(state: AppState) -> App { App { router } } - -trait RouterExt -where - B: HttpBody + Send + 'static, - S: Clone + Send + Sync + 'static, -{ - fn directory_route(self, path: &str, method_router: MethodRouter) -> Self; -} - -impl RouterExt for Router -where - B: HttpBody + Send + 'static, - S: Clone + Send + Sync + 'static, -{ - fn directory_route(self, path: &str, method_router: MethodRouter) -> Self { - self.route(path, method_router.clone()) - .route(&format!("{path}/"), method_router) - } -} diff --git a/server/src/models/bulk.rs b/server/src/models/bulk.rs index a4e5bb4..9560d11 100644 --- a/server/src/models/bulk.rs +++ b/server/src/models/bulk.rs @@ -1,5 +1,5 @@ use enstate_shared::core::{error::ProfileError, Profile}; -use utoipa::ToSchema; +// use utoipa::ToSchema; use crate::models::error::ErrorResponse; use crate::routes::profile_http_error_mapper; @@ -31,7 +31,7 @@ impl From> for BulkResponse { } } -#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, ToSchema)] +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] pub struct ListResponse { pub(crate) response_length: usize, pub(crate) response: Vec, diff --git a/server/src/models/error.rs b/server/src/models/error.rs index b078ebf..3f8f0fd 100644 --- a/server/src/models/error.rs +++ b/server/src/models/error.rs @@ -1,6 +1,4 @@ -use utoipa::ToSchema; - -#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)] +#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ErrorResponse { pub(crate) status: u16, pub(crate) error: String, diff --git a/server/src/models/profile.rs b/server/src/models/profile.rs index e3c9e19..fb08ddb 100644 --- a/server/src/models/profile.rs +++ b/server/src/models/profile.rs @@ -1,9 +1,8 @@ use std::collections::BTreeMap; use enstate_shared::core::Profile; -use utoipa::ToSchema; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct ENSProfile { // Name pub name: String, diff --git a/server/src/routes/address.rs b/server/src/routes/address.rs index 6728704..4d266db 100644 --- a/server/src/routes/address.rs +++ b/server/src/routes/address.rs @@ -23,19 +23,19 @@ use crate::routes::{ RouteError, }; -#[utoipa::path( - get, - path = "/a/{address}", - responses( - (status = 200, description = "Successfully found address.", body = ENSProfile), - (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), - (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), - (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), - ), - params( - ("address" = String, Path, description = "Address to lookup name data for"), - ) -)] +// #[utoipa::path( +// get, +// path = "/a/{address}", +// responses( +// (status = 200, description = "Successfully found address.", body = ENSProfile), +// (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), +// (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), +// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), +// ), +// params( +// ("address" = String, Path, description = "Address to lookup name data for"), +// ) +// )] pub async fn get( Path(address): Path, Query(query): Query, @@ -66,19 +66,19 @@ pub struct AddressGetBulkQuery { fresh: FreshQuery, } -#[utoipa::path( - get, - path = "/bulk/a/", - responses( - (status = 200, description = "Successfully found address.", body = BulkResponse), - (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), - (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), - (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), - ), - params( - ("addresses" = Vec, Path, description = "Addresses to lookup name data for"), - ) -)] +// #[utoipa::path( +// get, +// path = "/bulk/a/", +// responses( +// (status = 200, description = "Successfully found address.", body = BulkResponse), +// (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), +// (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), +// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), +// ), +// params( +// ("addresses" = Vec, Path, description = "Addresses to lookup name data for"), +// ) +// )] pub async fn get_bulk( Qs(query): Qs, State(state): State>, diff --git a/server/src/routes/name.rs b/server/src/routes/name.rs index 4f04082..1358947 100644 --- a/server/src/routes/name.rs +++ b/server/src/routes/name.rs @@ -18,17 +18,17 @@ use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::sse::SSEResponse; use crate::routes::{profile_http_error_mapper, validate_bulk_input, FreshQuery, Qs, RouteError}; -#[utoipa::path( - get, - path = "/n/{name}", - responses( - (status = 200, description = "Successfully found name.", body = ENSProfile), - (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), - ), - params( - ("name" = String, Path, description = "Name to lookup the name data for."), - ) -)] +// #[utoipa::path( +// get, +// path = "/n/{name}", +// responses( +// (status = 200, description = "Successfully found name.", body = ENSProfile), +// (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), +// ), +// params( +// ("name" = String, Path, description = "Name to lookup the name data for."), +// ) +// )] pub async fn get( Path(name): Path, Query(query): Query, @@ -59,17 +59,17 @@ pub struct NameGetBulkQuery { fresh: FreshQuery, } -#[utoipa::path( - get, - path = "/bulk/n/", - responses( - (status = 200, description = "Successfully found name.", body = ListButWithLength>), - (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), - ), - params( - ("name" = String, Path, description = "Name to lookup the name data for."), - ) -)] +// #[utoipa::path( +// get, +// path = "/bulk/n/", +// responses( +// (status = 200, description = "Successfully found name.", body = ListButWithLength>), +// (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), +// ), +// params( +// ("name" = String, Path, description = "Name to lookup the name data for."), +// ) +// )] pub async fn get_bulk( Qs(query): Qs, State(state): State>, diff --git a/server/src/routes/universal.rs b/server/src/routes/universal.rs index 4c89348..e4f5cde 100644 --- a/server/src/routes/universal.rs +++ b/server/src/routes/universal.rs @@ -19,18 +19,18 @@ use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::sse::SSEResponse; use crate::routes::{profile_http_error_mapper, validate_bulk_input, FreshQuery, Qs, RouteError}; -#[utoipa::path( - get, - path = "/u/{name_or_address}", - responses( - (status = 200, description = "Successfully found name or address.", body = ENSProfile), - (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), - (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), - ), - params( - ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), - ) -)] +// #[utoipa::path( +// get, +// path = "/u/{name_or_address}", +// responses( +// (status = 200, description = "Successfully found name or address.", body = ENSProfile), +// (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), +// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), +// ), +// params( +// ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), +// ) +// )] pub async fn get( Path(name_or_address): Path, Query(query): Query, @@ -61,18 +61,18 @@ pub struct UniversalGetBulkQuery { fresh: FreshQuery, } -#[utoipa::path( - get, - path = "/bulk/u/", - responses( - (status = 200, description = "Successfully found name or address.", body = BulkResponse), - (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), - (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), - ), - params( - ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), - ) -)] +// #[utoipa::path( +// get, +// path = "/bulk/u/", +// responses( +// (status = 200, description = "Successfully found name or address.", body = BulkResponse), +// (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), +// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), +// ), +// params( +// ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), +// ) +// )] pub async fn get_bulk( Qs(query): Qs, State(state): State>, From 2314d7f6406ab55f17aedeb94a6d3a9aaa3701c2 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 14:48:37 +0000 Subject: [PATCH 2/8] Introduce Basic Scalar --- server/Cargo.lock | 163 +++++++++++++++++++++-------------- server/Cargo.toml | 3 +- server/src/docs/index.html | 23 +++++ server/src/docs/mod.rs | 15 ++++ server/src/http.rs | 29 +++---- server/src/main.rs | 1 + server/src/models/bulk.rs | 3 +- server/src/models/error.rs | 4 +- server/src/models/profile.rs | 9 +- 9 files changed, 163 insertions(+), 87 deletions(-) create mode 100644 server/src/docs/index.html create mode 100644 server/src/docs/mod.rs diff --git a/server/Cargo.lock b/server/Cargo.lock index 8e4e3ea..b516207 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -47,27 +47,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "aide" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0e3b97a21e41ec5c19bfd9b4fc1f7086be104f8b988681230247ffc91cc8ed" -dependencies = [ - "axum 0.7.5", - "bytes", - "cfg-if", - "http 1.1.0", - "indexmap 2.2.6", - "schemars", - "serde", - "serde_json", - "serde_qs", - "thiserror", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "android-tzdata" version = "0.1.1" @@ -1082,12 +1061,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" -[[package]] -name = "dyn-clone" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" - [[package]] name = "ecdsa" version = "0.16.8" @@ -1167,7 +1140,6 @@ dependencies = [ name = "enstate" version = "1.0.1-2" dependencies = [ - "aide", "anyhow", "axum 0.7.5", "axum-macros", @@ -1210,6 +1182,8 @@ dependencies = [ "tracing", "tracing-opentelemetry", "tracing-subscriber", + "utoipa", + "utoipa-swagger-ui", ] [[package]] @@ -2448,7 +2422,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -2531,6 +2505,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3484,6 +3468,40 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "rust-embed" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn 2.0.38", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +dependencies = [ + "sha2", + "walkdir", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -3651,31 +3669,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "schemars" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" -dependencies = [ - "dyn-clone", - "indexmap 2.2.6", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 1.0.109", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -3782,17 +3775,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "serde_derive_internals" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "serde_json" version = "1.0.108" @@ -3820,8 +3802,6 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd34f36fe4c5ba9654417139a9b3a20d2e1de6012ee678ad14d240c22c78d8d6" dependencies = [ - "axum 0.7.5", - "futures", "percent-encoding", "serde", "thiserror", @@ -4646,6 +4626,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -4708,6 +4697,46 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utoipa" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "272ebdfbc99111033031d2f10e018836056e4d2c8e2acda76450ec7974269fa7" +dependencies = [ + "indexmap 2.2.6", + "serde", + "serde_json", + "utoipa-gen", +] + +[[package]] +name = "utoipa-gen" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3c9f4d08338c1bfa70dde39412a040a884c6f318b3d09aaaf3437a1e52027fc" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.38", +] + +[[package]] +name = "utoipa-swagger-ui" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b39868d43c011961e04b41623e050aedf2cc93652562ff7935ce0f819aaf2da" +dependencies = [ + "axum 0.7.5", + "mime_guess", + "regex", + "rust-embed", + "serde", + "serde_json", + "utoipa", + "zip", +] + [[package]] name = "uuid" version = "0.8.2" diff --git a/server/Cargo.toml b/server/Cargo.toml index b519c87..ffb6117 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -58,4 +58,5 @@ opentelemetry = "0.22.0" opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] } opentelemetry-otlp = "0.15.0" tracing-opentelemetry = "0.23.0" -aide = { version = "0.13.4", features = ["axum", "scalar"] } +utoipa = "4.2.0" +utoipa-swagger-ui = { version = "6.0.0", features = ["axum"] } diff --git a/server/src/docs/index.html b/server/src/docs/index.html new file mode 100644 index 0000000..9b482bf --- /dev/null +++ b/server/src/docs/index.html @@ -0,0 +1,23 @@ + + + + API Reference + + + + + + + + + diff --git a/server/src/docs/mod.rs b/server/src/docs/mod.rs new file mode 100644 index 0000000..f74c85c --- /dev/null +++ b/server/src/docs/mod.rs @@ -0,0 +1,15 @@ +use crate::models::bulk::{BulkResponse, ListResponse}; +use crate::models::error::ErrorResponse; +use crate::models::profile::ENSProfile; +use utoipa::OpenApi; + +#[derive(OpenApi)] +#[openapi( + // paths(crate::routes::address::get, crate::routes::name::get, crate::routes::universal::get), + components(schemas(ENSProfile, ListResponse>, ErrorResponse)) +)] +pub struct ApiDoc; + +pub async fn openapi() -> String { + ApiDoc::openapi().to_json().unwrap() +} diff --git a/server/src/http.rs b/server/src/http.rs index 3c8f048..a013814 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -1,29 +1,18 @@ +use axum::response::Html; use std::{net::SocketAddr, sync::Arc}; +use utoipa::OpenApi; +use utoipa_swagger_ui::SwaggerUi; -use axum::body::HttpBody; -use axum::routing::MethodRouter; use axum::{routing::get, Router}; use tokio::net::TcpListener; use tokio_util::sync::CancellationToken; use tower_http::cors::CorsLayer; use tower_http::trace::TraceLayer; use tracing::info; -// use utoipa::OpenApi; -// use utoipa_swagger_ui::SwaggerUi; -use crate::models::bulk::{BulkResponse, ListResponse}; -use crate::models::error::ErrorResponse; -use crate::models::profile::ENSProfile; use crate::routes; use crate::state::AppState; -// #[derive(OpenApi)] -// #[openapi( -// paths(routes::address::get, routes::name::get, routes::universal::get), -// components(schemas(ENSProfile, ListResponse>, ErrorResponse)) -// )] -// pub struct ApiDoc; - pub struct App { router: Router, } @@ -57,8 +46,10 @@ impl App { pub fn setup(state: AppState) -> App { let router = Router::new() - // .merge(SwaggerUi::new("/docs").url("/docs/openapi.json", ApiDoc::openapi())) - .route("/", get(routes::root::get)) + .route("/", get(scalar_handler)) + .route("/docs/openapi.json", get(crate::docs::openapi)) + // .merge(SwaggerUi::new("/docs").url("/docs/openapi.json", crate::docs::ApiDoc::openapi())) + .route("/this", get(routes::root::get)) .route("/a/:address", get(routes::address::get)) .route("/n/:name", get(routes::name::get)) .route("/u/:name_or_address", get(routes::universal::get)) @@ -77,3 +68,9 @@ pub fn setup(state: AppState) -> App { App { router } } + +// Loads from docs/index.html with headers html +async fn scalar_handler() -> Html<&'static str> { + let contents = include_str!("./docs/index.html"); + axum::response::Html(contents) +} diff --git a/server/src/main.rs b/server/src/main.rs index b2943da..0e9b252 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -13,6 +13,7 @@ use state::AppState; mod abi; mod cache; mod database; +mod docs; mod http; mod models; mod provider; diff --git a/server/src/models/bulk.rs b/server/src/models/bulk.rs index 9560d11..05a76c5 100644 --- a/server/src/models/bulk.rs +++ b/server/src/models/bulk.rs @@ -1,4 +1,5 @@ use enstate_shared::core::{error::ProfileError, Profile}; +use utoipa::ToSchema; // use utoipa::ToSchema; use crate::models::error::ErrorResponse; @@ -31,7 +32,7 @@ impl From> for BulkResponse { } } -#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)] +#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, ToSchema)] pub struct ListResponse { pub(crate) response_length: usize, pub(crate) response: Vec, diff --git a/server/src/models/error.rs b/server/src/models/error.rs index 3f8f0fd..b078ebf 100644 --- a/server/src/models/error.rs +++ b/server/src/models/error.rs @@ -1,4 +1,6 @@ -#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +use utoipa::ToSchema; + +#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)] pub struct ErrorResponse { pub(crate) status: u16, pub(crate) error: String, diff --git a/server/src/models/profile.rs b/server/src/models/profile.rs index fb08ddb..5317473 100644 --- a/server/src/models/profile.rs +++ b/server/src/models/profile.rs @@ -1,24 +1,31 @@ use std::collections::BTreeMap; use enstate_shared::core::Profile; +use utoipa::ToSchema; -#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)] pub struct ENSProfile { // Name + #[schema(example = "vitalik.eth")] pub name: String, // Ethereum Mainnet Address + #[schema(example = "0x225f137127d9067788314bc7fcc1f36746a3c3B5")] pub address: Option, // Avatar URL + #[schema(example = "https://cloudflare-ipfs.com/ipfs/bafkreifnrjhkl7ccr2ifwn2n7ap6dh2way25a6w5x2szegvj5pt4b5nvfu")] pub avatar: Option, // Preferred Capitalization of Name + #[schema(example = "LuC.eTh")] pub display: String, // Records pub records: BTreeMap, // Addresses on different chains pub chains: BTreeMap, // Unix Timestamp of date it was loaded + #[schema(example = "1713363899484")] pub fresh: i64, // Resolver the information was fetched from + #[schema(example = "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41")] pub resolver: String, // Errors encountered while fetching & decoding pub errors: BTreeMap, From 62d60615215686e645c5cd14601f82a6a63fe24f Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:14:43 +0000 Subject: [PATCH 3/8] Improve Documentation --- server/src/docs/mod.rs | 16 +++++++++++-- server/src/routes/address.rs | 26 ++++++++++---------- server/src/routes/name.rs | 44 +++++++++++++++++----------------- server/src/routes/universal.rs | 24 +++++++++---------- 4 files changed, 61 insertions(+), 49 deletions(-) diff --git a/server/src/docs/mod.rs b/server/src/docs/mod.rs index f74c85c..3dc2f86 100644 --- a/server/src/docs/mod.rs +++ b/server/src/docs/mod.rs @@ -1,15 +1,27 @@ use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::error::ErrorResponse; use crate::models::profile::ENSProfile; +use utoipa::openapi::{ExternalDocs, License}; use utoipa::OpenApi; #[derive(OpenApi)] #[openapi( - // paths(crate::routes::address::get, crate::routes::name::get, crate::routes::universal::get), + info( + title = "enstate.rs", + description = "A hosted ENS API allowing for easy access to ENS data.", + ), + paths(crate::routes::address::get, crate::routes::name::get, crate::routes::universal::get), components(schemas(ENSProfile, ListResponse>, ErrorResponse)) )] pub struct ApiDoc; pub async fn openapi() -> String { - ApiDoc::openapi().to_json().unwrap() + let mut doc = ApiDoc::openapi(); + + let license = License::new("GPLv3"); + + doc.info.license = Some(license); + doc.external_docs = Some(ExternalDocs::new("https://github.com/v3xlabs/enstate")); + + doc.to_json().unwrap() } diff --git a/server/src/routes/address.rs b/server/src/routes/address.rs index 4d266db..eac75d3 100644 --- a/server/src/routes/address.rs +++ b/server/src/routes/address.rs @@ -23,19 +23,19 @@ use crate::routes::{ RouteError, }; -// #[utoipa::path( -// get, -// path = "/a/{address}", -// responses( -// (status = 200, description = "Successfully found address.", body = ENSProfile), -// (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), -// (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), -// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), -// ), -// params( -// ("address" = String, Path, description = "Address to lookup name data for"), -// ) -// )] +#[utoipa::path( + get, + path = "/a/{address}", + responses( + (status = 200, description = "Successfully found address.", body = ENSProfile), + (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), + (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), + (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), + ), + params( + ("address" = String, Path, description = "Address to lookup name data for"), + ) +)] pub async fn get( Path(address): Path, Query(query): Query, diff --git a/server/src/routes/name.rs b/server/src/routes/name.rs index 1358947..4f04082 100644 --- a/server/src/routes/name.rs +++ b/server/src/routes/name.rs @@ -18,17 +18,17 @@ use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::sse::SSEResponse; use crate::routes::{profile_http_error_mapper, validate_bulk_input, FreshQuery, Qs, RouteError}; -// #[utoipa::path( -// get, -// path = "/n/{name}", -// responses( -// (status = 200, description = "Successfully found name.", body = ENSProfile), -// (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), -// ), -// params( -// ("name" = String, Path, description = "Name to lookup the name data for."), -// ) -// )] +#[utoipa::path( + get, + path = "/n/{name}", + responses( + (status = 200, description = "Successfully found name.", body = ENSProfile), + (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), + ), + params( + ("name" = String, Path, description = "Name to lookup the name data for."), + ) +)] pub async fn get( Path(name): Path, Query(query): Query, @@ -59,17 +59,17 @@ pub struct NameGetBulkQuery { fresh: FreshQuery, } -// #[utoipa::path( -// get, -// path = "/bulk/n/", -// responses( -// (status = 200, description = "Successfully found name.", body = ListButWithLength>), -// (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), -// ), -// params( -// ("name" = String, Path, description = "Name to lookup the name data for."), -// ) -// )] +#[utoipa::path( + get, + path = "/bulk/n/", + responses( + (status = 200, description = "Successfully found name.", body = ListButWithLength>), + (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), + ), + params( + ("name" = String, Path, description = "Name to lookup the name data for."), + ) +)] pub async fn get_bulk( Qs(query): Qs, State(state): State>, diff --git a/server/src/routes/universal.rs b/server/src/routes/universal.rs index e4f5cde..bd96450 100644 --- a/server/src/routes/universal.rs +++ b/server/src/routes/universal.rs @@ -19,18 +19,18 @@ use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::sse::SSEResponse; use crate::routes::{profile_http_error_mapper, validate_bulk_input, FreshQuery, Qs, RouteError}; -// #[utoipa::path( -// get, -// path = "/u/{name_or_address}", -// responses( -// (status = 200, description = "Successfully found name or address.", body = ENSProfile), -// (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), -// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), -// ), -// params( -// ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), -// ) -// )] +#[utoipa::path( + get, + path = "/u/{name_or_address}", + responses( + (status = 200, description = "Successfully found name or address.", body = ENSProfile), + (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), + (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), + ), + params( + ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), + ) +)] pub async fn get( Path(name_or_address): Path, Query(query): Query, From 4cb376d946c579e078b578dd5552efd6c2d46991 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:19:54 +0000 Subject: [PATCH 4/8] Bump --- server/src/docs/mod.rs | 5 ++++- server/src/routes/address.rs | 26 +++++++++++++------------- server/src/routes/name.rs | 2 +- server/src/routes/universal.rs | 24 ++++++++++++------------ 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/server/src/docs/mod.rs b/server/src/docs/mod.rs index 3dc2f86..8382bd1 100644 --- a/server/src/docs/mod.rs +++ b/server/src/docs/mod.rs @@ -10,7 +10,10 @@ use utoipa::OpenApi; title = "enstate.rs", description = "A hosted ENS API allowing for easy access to ENS data.", ), - paths(crate::routes::address::get, crate::routes::name::get, crate::routes::universal::get), + paths( + crate::routes::address::get, crate::routes::name::get, crate::routes::universal::get, + crate::routes::address::get_bulk, crate::routes::name::get_bulk, crate::routes::universal::get_bulk + ), components(schemas(ENSProfile, ListResponse>, ErrorResponse)) )] pub struct ApiDoc; diff --git a/server/src/routes/address.rs b/server/src/routes/address.rs index eac75d3..f202ee5 100644 --- a/server/src/routes/address.rs +++ b/server/src/routes/address.rs @@ -66,19 +66,19 @@ pub struct AddressGetBulkQuery { fresh: FreshQuery, } -// #[utoipa::path( -// get, -// path = "/bulk/a/", -// responses( -// (status = 200, description = "Successfully found address.", body = BulkResponse), -// (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), -// (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), -// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), -// ), -// params( -// ("addresses" = Vec, Path, description = "Addresses to lookup name data for"), -// ) -// )] +#[utoipa::path( + get, + path = "/bulk/a", + responses( + (status = 200, description = "Successfully found address.", body = BulkResponse), + (status = BAD_REQUEST, description = "Invalid address.", body = ErrorResponse), + (status = NOT_FOUND, description = "No name was associated with this address.", body = ErrorResponse), + (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), + ), + params( + ("addresses" = Vec, Path, description = "Addresses to lookup name data for"), + ) +)] pub async fn get_bulk( Qs(query): Qs, State(state): State>, diff --git a/server/src/routes/name.rs b/server/src/routes/name.rs index 4f04082..25f7b69 100644 --- a/server/src/routes/name.rs +++ b/server/src/routes/name.rs @@ -61,7 +61,7 @@ pub struct NameGetBulkQuery { #[utoipa::path( get, - path = "/bulk/n/", + path = "/bulk/n", responses( (status = 200, description = "Successfully found name.", body = ListButWithLength>), (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), diff --git a/server/src/routes/universal.rs b/server/src/routes/universal.rs index bd96450..af9c700 100644 --- a/server/src/routes/universal.rs +++ b/server/src/routes/universal.rs @@ -61,18 +61,18 @@ pub struct UniversalGetBulkQuery { fresh: FreshQuery, } -// #[utoipa::path( -// get, -// path = "/bulk/u/", -// responses( -// (status = 200, description = "Successfully found name or address.", body = BulkResponse), -// (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), -// (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), -// ), -// params( -// ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), -// ) -// )] +#[utoipa::path( + get, + path = "/bulk/u", + responses( + (status = 200, description = "Successfully found name or address.", body = BulkResponse), + (status = NOT_FOUND, description = "No name or address could be found.", body = ErrorResponse), + (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), + ), + params( + ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), + ) +)] pub async fn get_bulk( Qs(query): Qs, State(state): State>, From cd4ecf8a369dca5eb2be10de7949bad537e8e42a Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:28:22 +0000 Subject: [PATCH 5/8] Update OpenAPI Spec --- server/src/routes/address.rs | 2 +- server/src/routes/name.rs | 2 +- server/src/routes/universal.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/src/routes/address.rs b/server/src/routes/address.rs index f202ee5..4824f1b 100644 --- a/server/src/routes/address.rs +++ b/server/src/routes/address.rs @@ -76,7 +76,7 @@ pub struct AddressGetBulkQuery { (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), ), params( - ("addresses" = Vec, Path, description = "Addresses to lookup name data for"), + ("addresses[]" = Vec, Query, description = "Addresses to lookup name data for"), ) )] pub async fn get_bulk( diff --git a/server/src/routes/name.rs b/server/src/routes/name.rs index 25f7b69..069081d 100644 --- a/server/src/routes/name.rs +++ b/server/src/routes/name.rs @@ -67,7 +67,7 @@ pub struct NameGetBulkQuery { (status = NOT_FOUND, description = "No name could be found.", body = ErrorResponse), ), params( - ("name" = String, Path, description = "Name to lookup the name data for."), + ("names[]" = Vec, Query, description = "Names to lookup name data for"), ) )] pub async fn get_bulk( diff --git a/server/src/routes/universal.rs b/server/src/routes/universal.rs index af9c700..a1f794d 100644 --- a/server/src/routes/universal.rs +++ b/server/src/routes/universal.rs @@ -14,6 +14,7 @@ use enstate_shared::core::{ENSService, Profile}; use futures::future::join_all; use serde::Deserialize; use tokio_stream::wrappers::UnboundedReceiverStream; +use utoipa::IntoParams; use crate::models::bulk::{BulkResponse, ListResponse}; use crate::models::sse::SSEResponse; @@ -51,7 +52,7 @@ pub async fn get( })? } -#[derive(Deserialize)] +#[derive(Deserialize, IntoParams)] pub struct UniversalGetBulkQuery { // TODO (@antony1060): remove when proper serde error handling #[serde(default)] @@ -70,7 +71,7 @@ pub struct UniversalGetBulkQuery { (status = UNPROCESSABLE_ENTITY, description = "Reverse record not owned by this address.", body = ErrorResponse), ), params( - ("name_or_address" = String, Path, description = "Name or address to lookup the name data for."), + ("queries[]" = Vec, Query, description = "Names to lookup name data for"), ) )] pub async fn get_bulk( From fb52e0afc22ee4eeb38778c3f213159bb5cd32b6 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:34:57 +0000 Subject: [PATCH 6/8] Update Routes --- server/src/http.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/http.rs b/server/src/http.rs index a013814..4fd6bb7 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -1,4 +1,4 @@ -use axum::response::Html; +use axum::response::{Html, Redirect}; use std::{net::SocketAddr, sync::Arc}; use utoipa::OpenApi; use utoipa_swagger_ui::SwaggerUi; @@ -46,9 +46,12 @@ impl App { pub fn setup(state: AppState) -> App { let router = Router::new() - .route("/", get(scalar_handler)) + .route( + "/", + get(|| async { Redirect::temporary("/docs") }), + ) + .route("/docs", get(scalar_handler)) .route("/docs/openapi.json", get(crate::docs::openapi)) - // .merge(SwaggerUi::new("/docs").url("/docs/openapi.json", crate::docs::ApiDoc::openapi())) .route("/this", get(routes::root::get)) .route("/a/:address", get(routes::address::get)) .route("/n/:name", get(routes::name::get)) From 255a6330a19eb761fbaaaa0bef3f82c68ce85751 Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:35:53 +0000 Subject: [PATCH 7/8] Update Deps --- server/Cargo.lock | 70 ----------------------------------------------- server/Cargo.toml | 3 -- 2 files changed, 73 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index b516207..c863ca9 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1183,7 +1183,6 @@ dependencies = [ "tracing-opentelemetry", "tracing-subscriber", "utoipa", - "utoipa-swagger-ui", ] [[package]] @@ -2505,16 +2504,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -3468,40 +3457,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rust-embed" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" -dependencies = [ - "rust-embed-impl", - "rust-embed-utils", - "walkdir", -] - -[[package]] -name = "rust-embed-impl" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" -dependencies = [ - "proc-macro2", - "quote", - "rust-embed-utils", - "syn 2.0.38", - "walkdir", -] - -[[package]] -name = "rust-embed-utils" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" -dependencies = [ - "sha2", - "walkdir", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -4626,15 +4581,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] - [[package]] name = "unicode-bidi" version = "0.3.13" @@ -4721,22 +4667,6 @@ dependencies = [ "syn 2.0.38", ] -[[package]] -name = "utoipa-swagger-ui" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b39868d43c011961e04b41623e050aedf2cc93652562ff7935ce0f819aaf2da" -dependencies = [ - "axum 0.7.5", - "mime_guess", - "regex", - "rust-embed", - "serde", - "serde_json", - "utoipa", - "zip", -] - [[package]] name = "uuid" version = "0.8.2" diff --git a/server/Cargo.toml b/server/Cargo.toml index ffb6117..f87fb48 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -26,8 +26,6 @@ serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.28.0", features = ["full", "tracing"] } tokio-util = "0.7.10" futures = "0.3.29" -# utoipa = { version = "4.1.0", features = ["axum_extras"] } -# utoipa-swagger-ui = { version = "6.0.0", features = ["axum"] } redis = { version = "0.25.3", features = ["connection-manager", "tokio-comp"] } tower-http = { version = "0.5.2", features = ["cors", "tracing", "trace"] } rand = "0.8.5" @@ -59,4 +57,3 @@ opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] } opentelemetry-otlp = "0.15.0" tracing-opentelemetry = "0.23.0" utoipa = "4.2.0" -utoipa-swagger-ui = { version = "6.0.0", features = ["axum"] } From 7bd6560c2edbb60a0e52257939af8d4d7e7e6d7d Mon Sep 17 00:00:00 2001 From: Luc Date: Wed, 17 Apr 2024 15:40:51 +0000 Subject: [PATCH 8/8] Update Deps --- server/Cargo.toml | 58 +++++++++++++++++++++++---------------- server/src/models/bulk.rs | 1 - 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index f87fb48..d9b97d9 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -8,6 +8,7 @@ description = "enstate" repository = "https://github.com/v3xlabs/enstate" authors = [ "Luc van Kampen ", + "Jakob Helgesson ", "Antonio Fran Trstenjak ", "Miguel Piedrafita ", ] @@ -15,45 +16,56 @@ authors = [ [dependencies] enstate_shared = { path = "../shared" } -ethers = "2" +# Server +dotenvy = "0.15.7" axum = "0.7.5" anyhow = "1.0.71" -tracing = "0.1.27" -tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } -dotenvy = "0.15.7" -serde_json = "1.0.96" -serde = { version = "1.0", features = ["derive"] } +thiserror = "1.0.48" +futures = "0.3.29" tokio = { version = "1.28.0", features = ["full", "tracing"] } tokio-util = "0.7.10" -futures = "0.3.29" -redis = { version = "0.25.3", features = ["connection-manager", "tokio-comp"] } +tokio-stream = "0.1.14" tower-http = { version = "0.5.2", features = ["cors", "tracing", "trace"] } rand = "0.8.5" chrono = "0.4.31" -ethers-contract = "2.0.9" -ethers-core = "2.0.9" -hex = "0.4.3" -thiserror = "1.0.48" regex = "1.9.5" -rustls = "0.23" -bs58 = "0.5.0" -sha2 = "0.10.7" -digest = "0.10.7" hex-literal = "0.4.1" axum-macros = "0.4.1" lazy_static = "1.4.0" -base32 = "0.4.0" -crc16 = "0.4.0" -blake2 = "0.10.6" rustc-hex = "2.0.1" + +# Serde +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0.96" serde_with = "3.3.0" -bech32 = "0.10.0-alpha" -crc32fast = "1.3.2" -ciborium = "0.2.1" serde_qs = "0.13.0" -tokio-stream = "0.1.14" + +# Logging & Tracing +tracing = "0.1.27" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } opentelemetry = "0.22.0" opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] } opentelemetry-otlp = "0.15.0" tracing-opentelemetry = "0.23.0" + +# Ethereum +ethers = "2" +ethers-contract = "2.0.9" +ethers-core = "2.0.9" + +# Hashing +bs58 = "0.5.0" +sha2 = "0.10.7" +base32 = "0.4.0" +crc16 = "0.4.0" +blake2 = "0.10.6" +bech32 = "0.10.0-alpha" +crc32fast = "1.3.2" + +# Other +hex = "0.4.3" +redis = { version = "0.25.3", features = ["connection-manager", "tokio-comp"] } +rustls = "0.23" +digest = "0.10.7" +ciborium = "0.2.1" utoipa = "4.2.0" diff --git a/server/src/models/bulk.rs b/server/src/models/bulk.rs index 05a76c5..a4e5bb4 100644 --- a/server/src/models/bulk.rs +++ b/server/src/models/bulk.rs @@ -1,6 +1,5 @@ use enstate_shared::core::{error::ProfileError, Profile}; use utoipa::ToSchema; -// use utoipa::ToSchema; use crate::models::error::ErrorResponse; use crate::routes::profile_http_error_mapper;