From f71490c5fdecc056ff86322a44418511a93fd2db Mon Sep 17 00:00:00 2001 From: Franklin Date: Wed, 3 May 2023 20:07:58 -0400 Subject: [PATCH] Added Main router, dao, aws-s3, macros, etc... --- Cargo.lock | 692 +++++++++++++++++++ Cargo.toml | 4 + sqlx-data.json | 1346 +++++++++++++++++++++++++++++++++++++ src/dao/main_dao.rs | 10 + src/dao/mod.rs | 2 + src/main.rs | 24 +- src/routes/click.rs | 0 src/routes/main_router.rs | 61 ++ src/routes/mod.rs | 6 + src/routes/project.rs | 0 src/routes/property.rs | 0 src/routes/realtor.rs | 0 src/routes/trackable.rs | 0 src/routes/view.rs | 0 src/services/click.rs | 0 src/services/mod.rs | 7 +- src/services/property.rs | 0 src/services/trackable.rs | 0 src/services/view.rs | 0 src/utils/mod.rs | 2 + src/utils/s3.rs | 31 + 21 files changed, 2183 insertions(+), 2 deletions(-) create mode 100644 sqlx-data.json create mode 100644 src/routes/click.rs create mode 100644 src/routes/project.rs create mode 100644 src/routes/property.rs create mode 100644 src/routes/realtor.rs create mode 100644 src/routes/trackable.rs create mode 100644 src/routes/view.rs create mode 100644 src/services/click.rs create mode 100644 src/services/property.rs create mode 100644 src/services/trackable.rs create mode 100644 src/services/view.rs create mode 100644 src/utils/s3.rs diff --git a/Cargo.lock b/Cargo.lock index 618272b..64ef42e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -420,6 +420,367 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "aws-config" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc00553f5f3c06ffd4510a9d576f92143618706c45ea6ff81e84ad9be9588abd" +dependencies = [ + "aws-credential-types", + "aws-http", + "aws-sdk-sso", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "hex", + "http", + "hyper", + "ring", + "time 0.3.20", + "tokio", + "tower", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-credential-types" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cb57ac6088805821f78d282c0ba8aec809f11cbee10dda19a97b03ab040ccc2" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "fastrand", + "tokio", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-endpoint" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5f6f84a4f46f95a9bb71d9300b73cd67eb868bc43ae84f66ad34752299f4ac" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "aws-types", + "http", + "regex", + "tracing", +] + +[[package]] +name = "aws-http" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a754683c322f7dc5167484266489fdebdcd04d26e53c162cad1f3f949f2c5671" +dependencies = [ + "aws-credential-types", + "aws-smithy-http", + "aws-smithy-types", + "aws-types", + "bytes", + "http", + "http-body", + "lazy_static", + "percent-encoding", + "pin-project-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-s3" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b64fc8b7d76d09e53f4a64ebe2cd44894adb902011a26878aebd0576234d41" +dependencies = [ + "aws-credential-types", + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-checksums", + "aws-smithy-client", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "http", + "http-body", + "once_cell", + "percent-encoding", + "regex", + "tokio-stream", + "tower", + "tracing", + "url", +] + +[[package]] +name = "aws-sdk-sso" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "babfd626348836a31785775e3c08a4c345a5ab4c6e06dfd9167f2bee0e6295d6" +dependencies = [ + "aws-credential-types", + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-types", + "aws-types", + "bytes", + "http", + "regex", + "tokio-stream", + "tower", + "tracing", +] + +[[package]] +name = "aws-sdk-sts" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d0fbe3c2c342bc8dfea4bb43937405a8ec06f99140a0dcb9c7b59e54dfa93a1" +dependencies = [ + "aws-credential-types", + "aws-endpoint", + "aws-http", + "aws-sig-auth", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "bytes", + "http", + "regex", + "tower", + "tracing", +] + +[[package]] +name = "aws-sig-auth" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84dc92a63ede3c2cbe43529cb87ffa58763520c96c6a46ca1ced80417afba845" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-eventstream", + "aws-smithy-http", + "aws-types", + "http", + "tracing", +] + +[[package]] +name = "aws-sigv4" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "392fefab9d6fcbd76d518eb3b1c040b84728ab50f58df0c3c53ada4bea9d327e" +dependencies = [ + "aws-smithy-eventstream", + "aws-smithy-http", + "bytes", + "form_urlencoded", + "hex", + "hmac", + "http", + "once_cell", + "percent-encoding", + "regex", + "sha2", + "time 0.3.20", + "tracing", +] + +[[package]] +name = "aws-smithy-async" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae23b9fe7a07d0919000116c4c5c0578303fbce6fc8d32efca1f7759d4c20faf" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", + "tokio-stream", +] + +[[package]] +name = "aws-smithy-checksums" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6367acbd6849b8c7c659e166955531274ae147bf83ab4312885991f6b6706cb" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "bytes", + "crc32c", + "crc32fast", + "hex", + "http", + "http-body", + "md-5", + "pin-project-lite", + "sha1", + "sha2", + "tracing", +] + +[[package]] +name = "aws-smithy-client" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5230d25d244a51339273b8870f0f77874cd4449fb4f8f629b21188ae10cfc0ba" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-http-tower", + "aws-smithy-types", + "bytes", + "fastrand", + "http", + "http-body", + "hyper", + "hyper-rustls", + "lazy_static", + "pin-project-lite", + "rustls", + "tokio", + "tower", + "tracing", +] + +[[package]] +name = "aws-smithy-eventstream" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22d2a2bcc16e5c4d949ffd2b851da852b9bbed4bb364ed4ae371b42137ca06d9" +dependencies = [ + "aws-smithy-types", + "bytes", + "crc32fast", +] + +[[package]] +name = "aws-smithy-http" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b60e2133beb9fe6ffe0b70deca57aaeff0a35ad24a9c6fab2fd3b4f45b99fdb5" +dependencies = [ + "aws-smithy-eventstream", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http", + "http-body", + "hyper", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "aws-smithy-http-tower" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4d94f556c86a0dd916a5d7c39747157ea8cb909ca469703e20fee33e448b67" +dependencies = [ + "aws-smithy-http", + "aws-smithy-types", + "bytes", + "http", + "http-body", + "pin-project-lite", + "tower", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3d6e6ebb00b2cce379f079ad5ec508f9bcc3a9510d9b9c1840ed1d6f8af39" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-query" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58edfca32ef9bfbc1ca394599e17ea329cb52d6a07359827be74235b64b3298" +dependencies = [ + "aws-smithy-types", + "urlencoding", +] + +[[package]] +name = "aws-smithy-types" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58db46fc1f4f26be01ebdb821751b4e2482cd43aa2b64a0348fb89762defaffa" +dependencies = [ + "base64-simd", + "itoa", + "num-integer", + "ryu", + "time 0.3.20", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb557fe4995bd9ec87fb244bbb254666a971dc902a783e9da8b7711610e9664c" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "0.55.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0869598bfe46ec44ffe17e063ed33336e59df90356ca8ff0e8da6f7c1d994b" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-client", + "aws-smithy-http", + "aws-smithy-types", + "http", + "rustc_version", + "tracing", +] + [[package]] name = "base64" version = "0.13.1" @@ -432,6 +793,16 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + [[package]] name = "bincode" version = "1.3.3" @@ -495,6 +866,16 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +[[package]] +name = "bytes-utils" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e47d3a8076e283f3acd27400535992edb3ba4b5bb72f8891ad8fbe7932a7d4b9" +dependencies = [ + "bytes", + "either", +] + [[package]] name = "bytestring" version = "1.3.0" @@ -584,6 +965,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.4" @@ -614,6 +1005,15 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +[[package]] +name = "crc32c" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dfea2db42e9927a3845fb268a10a72faed6d416065f77873f05e411457c363e" +dependencies = [ + "rustc_version", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -937,6 +1337,12 @@ dependencies = [ "parking_lot 0.11.2", ] +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + [[package]] name = "futures-sink" version = "0.3.28" @@ -956,8 +1362,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", + "futures-io", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", "slab", @@ -1082,6 +1490,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + [[package]] name = "http-range" version = "0.1.5" @@ -1100,6 +1519,45 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "hyper" +version = "0.14.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +dependencies = [ + "http", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + [[package]] name = "iana-time-zone" version = "0.1.56" @@ -1176,6 +1634,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + [[package]] name = "itertools" version = "0.10.5" @@ -1215,6 +1679,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.142" @@ -1383,6 +1853,18 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + [[package]] name = "parking_lot" version = "0.11.2" @@ -1496,6 +1978,26 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1577,6 +2079,8 @@ dependencies = [ "actix-web", "actix-web-lab", "actix-web-utils", + "aws-config", + "aws-sdk-s3", "chrono", "chrono-tz", "dotenvy", @@ -1584,6 +2088,7 @@ dependencies = [ "err", "rand", "realtor-lp-types", + "reqwest", "serde", "serde_json", "sqlx", @@ -1652,6 +2157,45 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" +[[package]] +name = "reqwest" +version = "0.11.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" +dependencies = [ + "base64 0.21.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + [[package]] name = "ring" version = "0.16.20" @@ -1702,6 +2246,18 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls-native-certs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "1.0.2" @@ -1717,6 +2273,15 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -1739,6 +2304,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.17" @@ -2192,6 +2780,34 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2225,6 +2841,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "typenum" version = "1.16.0" @@ -2296,6 +2918,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" + [[package]] name = "uuid" version = "1.3.2" @@ -2326,6 +2954,22 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" @@ -2363,6 +3007,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.84" @@ -2471,6 +3127,21 @@ dependencies = [ "windows-targets 0.48.0", ] +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -2603,6 +3274,27 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "xmlparser" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" + [[package]] name = "zstd" version = "0.12.3+zstd.1.5.2" diff --git a/Cargo.toml b/Cargo.toml index 4f8f739..cb2f717 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ dotenvy_macro = "0.15.1" tokio = {version = "1.20.1", features = ["full"]} chrono = "0.4.23" chrono-tz = "0.8" +reqwest = { version = "0.11.11", features = ["rustls-tls", "json", "blocking"], default-features = false } + serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.88" sqlx = { version = "0.6.0", features = [ "runtime-tokio-rustls", "postgres", "chrono", "uuid", "offline" ] } @@ -20,6 +22,8 @@ actix-multipart = "0.6.0" actix-web-lab = { version = "0.19.1", features = [ "spa" ]} uuid = { version = "1.3.0", features = ["v4", "fast-rng", "macro-diagnostics"] } rand = "0.8.5" +aws-sdk-s3 = "0.26.0" +aws-config = "0.55.1" actix-web-utils = { git = "https://git.franklinblanco.dev/franklinblanco/actix-web-utils.git" } err = { git = "https://git.franklinblanco.dev/franklinblanco/err.git" } diff --git a/sqlx-data.json b/sqlx-data.json new file mode 100644 index 0000000..48aa927 --- /dev/null +++ b/sqlx-data.json @@ -0,0 +1,1346 @@ +{ + "db": "PostgreSQL", + "05a794cb8f74d38e21c59094af5e0ac12284cdb4bc3a4ecd53c6dff764fa435e": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "title", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "description", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "realtor_id", + "ordinal": 3, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "project_condition: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "project_type: _", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "project_state: _", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 9, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 10, + "type_info": "Varchar" + }, + { + "name": "admin_tag", + "ordinal": 11, + "type_info": "Varchar" + }, + { + "name": "floors", + "ordinal": 12, + "type_info": "Int2" + }, + { + "name": "finish_date", + "ordinal": 13, + "type_info": "Date" + }, + { + "name": "order_index", + "ordinal": 14, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 15, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 16, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid" + ] + } + }, + "query": "SELECT \n id,\n title,\n description,\n realtor_id,\n media as \"media: _\",\n project_condition as \"project_condition: _\",\n project_type as \"project_type: _\",\n project_state as \"project_state: _\",\n country,\n city, \n district,\n admin_tag,\n floors,\n finish_date,\n order_index,\n time_created,\n last_updated\nFROM project WHERE id = $1;\n" + }, + "1de871eb06903280d3be4e4ef8f67cde596807784e726ff62d03c2c9f6d6ba76": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "name", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "bio", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "phone_number", + "ordinal": 3, + "type_info": "Varchar" + }, + { + "name": "email", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "profile_picture_url", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "show_projects", + "ordinal": 6, + "type_info": "Bool" + }, + { + "name": "shortcode", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "remax_agent_id", + "ordinal": 8, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 9, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 10, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Text" + ] + } + }, + "query": "SELECT * FROM realtor WHERE shortcode = $1;" + }, + "2482798d8601fd41678197770bf51af67cd962d210ff65b9236f24f0425d7341": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "name", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "bio", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "phone_number", + "ordinal": 3, + "type_info": "Varchar" + }, + { + "name": "email", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "profile_picture_url", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "show_projects", + "ordinal": 6, + "type_info": "Bool" + }, + { + "name": "shortcode", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "remax_agent_id", + "ordinal": 8, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 9, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 10, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Bool", + "Varchar", + "Int4", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO realtor (\n id, name, bio, phone_number, email, profile_picture_url, show_projects, shortcode, remax_agent_id, time_created, last_updated\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $10\n) RETURNING *;" + }, + "39cc220eaa29a94125da6d2baf3fc82a26c1ee626f3ecacb2b1cab3151cbe00c": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "project_id", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "realtor_id", + "ordinal": 2, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 3, + "type_info": "Text" + }, + { + "name": "property_type: _", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "property_sale_type: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "price_usd", + "ordinal": 9, + "type_info": "Float8" + }, + { + "name": "rooms", + "ordinal": 10, + "type_info": "Int2" + }, + { + "name": "bathrooms", + "ordinal": 11, + "type_info": "Float4" + }, + { + "name": "area", + "ordinal": 12, + "type_info": "Float4" + }, + { + "name": "admin_tag", + "ordinal": 13, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 14, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 15, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid" + ] + } + }, + "query": "SELECT \n id,\n project_id,\n realtor_id,\n media as \"media: _\",\n property_type as \"property_type: _\",\n property_sale_type as \"property_sale_type: _\",\n country,\n city,\n district,\n price_usd,\n rooms,\n bathrooms,\n area,\n admin_tag,\n time_created,\n last_updated\nFROM property WHERE id = $1;" + }, + "3acc0efdfdf6fd4e86b0f197cd27b7378507b82915127b76a6cf76a8f7cb5618": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "who_was", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "ip_address", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "browser_width", + "ordinal": 3, + "type_info": "Int4" + }, + { + "name": "browser_height", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "user_agent", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 6, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid" + ] + } + }, + "query": "SELECT * FROM trackable WHERE id = $1;" + }, + "45b2fd6a4b72efa359a9f8da7d7dede96bd0d2451abd0127f9e4b89bd1e69c1d": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "title", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "description", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "realtor_id", + "ordinal": 3, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "project_condition: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "project_type: _", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "project_state: _", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 9, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 10, + "type_info": "Varchar" + }, + { + "name": "admin_tag", + "ordinal": 11, + "type_info": "Varchar" + }, + { + "name": "floors", + "ordinal": 12, + "type_info": "Int2" + }, + { + "name": "finish_date", + "ordinal": 13, + "type_info": "Date" + }, + { + "name": "order_index", + "ordinal": 14, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 15, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 16, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Text", + "Uuid", + "Text", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Int2", + "Date", + "Int4", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO project (\n id,\n title,\n description,\n realtor_id,\n media,\n project_condition,\n project_type,\n project_state,\n country,\n city, \n district,\n admin_tag,\n floors,\n finish_date,\n order_index,\n time_created,\n last_updated\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $16\n) RETURNING \n id,\n title,\n description,\n realtor_id,\n media as \"media: _\",\n project_condition as \"project_condition: _\",\n project_type as \"project_type: _\",\n project_state as \"project_state: _\",\n country,\n city, \n district,\n admin_tag,\n floors,\n finish_date,\n order_index,\n time_created,\n last_updated;" + }, + "5cb3e189c5a575ebe13353f8824ac7baa96a9937ab7735216e064583f6cd68bc": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "title", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "description", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "realtor_id", + "ordinal": 3, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "project_condition: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "project_type: _", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "project_state: _", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 9, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 10, + "type_info": "Varchar" + }, + { + "name": "admin_tag", + "ordinal": 11, + "type_info": "Varchar" + }, + { + "name": "floors", + "ordinal": 12, + "type_info": "Int2" + }, + { + "name": "finish_date", + "ordinal": 13, + "type_info": "Date" + }, + { + "name": "order_index", + "ordinal": 14, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 15, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 16, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false, + false, + false, + false, + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Text", + "Uuid", + "Text", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Int2", + "Date", + "Int4", + "Timestamptz" + ] + } + }, + "query": "UPDATE project SET \n title = $2,\n description = $3,\n realtor_id = $4,\n media = $5,\n project_condition = $6,\n project_type = $7,\n project_state = $8,\n country = $9,\n city = $10,\n district = $11,\n admin_tag = $12,\n floors = $13,\n finish_date = $14,\n order_index = $15,\n last_updated = $16\nWHERE id = $1\nRETURNING \n id,\n title,\n description,\n realtor_id,\n media as \"media: _\",\n project_condition as \"project_condition: _\",\n project_type as \"project_type: _\",\n project_state as \"project_state: _\",\n country,\n city, \n district,\n admin_tag,\n floors,\n finish_date,\n order_index,\n time_created,\n last_updated;" + }, + "7464713d873ea4ad81fdbaef816eb57ce3bdcdf3aa669036e05158e230abd82c": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "thing_id", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "thing_pk: _", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "trackable_id", + "ordinal": 3, + "type_info": "Uuid" + }, + { + "name": "time_created", + "ordinal": 4, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Varchar", + "Uuid", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO view (\n id, thing_id, thing_pk, trackable_id, time_created\n) VALUES (\n $1, $2, $3, $4, $5\n) RETURNING \nid, thing_id, thing_pk as \"thing_pk: _\", trackable_id, time_created" + }, + "a6525881c04a3ddf038d566b8a41dc2e4670a20c0c6e4a0687a927538661db56": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "project_id", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "realtor_id", + "ordinal": 2, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 3, + "type_info": "Text" + }, + { + "name": "property_type: _", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "property_sale_type: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "price_usd", + "ordinal": 9, + "type_info": "Float8" + }, + { + "name": "rooms", + "ordinal": 10, + "type_info": "Int2" + }, + { + "name": "bathrooms", + "ordinal": 11, + "type_info": "Float4" + }, + { + "name": "area", + "ordinal": 12, + "type_info": "Float4" + }, + { + "name": "admin_tag", + "ordinal": 13, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 14, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 15, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Text", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Float8", + "Int2", + "Float4", + "Float4", + "Varchar", + "Timestamptz" + ] + } + }, + "query": "UPDATE property SET\n project_id = $2,\n realtor_id = $3,\n media = $4,\n property_type = $5,\n property_sale_type = $6,\n country = $7,\n city = $8,\n district = $9,\n price_usd = $10,\n rooms = $11,\n bathrooms = $12,\n area = $13,\n admin_tag = $14,\n last_updated = $15\nWHERE id = $1\nRETURNING \n id,\n project_id,\n realtor_id,\n media as \"media: _\",\n property_type as \"property_type: _\",\n property_sale_type as \"property_sale_type: _\",\n country,\n city,\n district,\n price_usd,\n rooms,\n bathrooms,\n area,\n admin_tag,\n time_created,\n last_updated;" + }, + "b64e2047bd463a7fd60c3c11ba087bc6f6ec7729bd7bd08dc0444265e9f42690": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "who_was", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "ip_address", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "browser_width", + "ordinal": 3, + "type_info": "Int4" + }, + { + "name": "browser_height", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "user_agent", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 6, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Varchar", + "Int4", + "Int4", + "Varchar", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO trackable (\n id, who_was, ip_address, browser_width, browser_height, user_agent, time_created\n) VALUES(\n $1, $2, $3, $4, $5, $6, $7\n) RETURNING *;" + }, + "ba31aaf3792054e90629a08ef393136e77d7300eb7ef111a0decc97c05d9cc87": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "project_id", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "realtor_id", + "ordinal": 2, + "type_info": "Uuid" + }, + { + "name": "media: _", + "ordinal": 3, + "type_info": "Text" + }, + { + "name": "property_type: _", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "property_sale_type: _", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "country", + "ordinal": 6, + "type_info": "Varchar" + }, + { + "name": "city", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "district", + "ordinal": 8, + "type_info": "Varchar" + }, + { + "name": "price_usd", + "ordinal": 9, + "type_info": "Float8" + }, + { + "name": "rooms", + "ordinal": 10, + "type_info": "Int2" + }, + { + "name": "bathrooms", + "ordinal": 11, + "type_info": "Float4" + }, + { + "name": "area", + "ordinal": 12, + "type_info": "Float4" + }, + { + "name": "admin_tag", + "ordinal": 13, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 14, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 15, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + true, + true, + true, + false, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Text", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Float8", + "Int2", + "Float4", + "Float4", + "Varchar", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO property (\n id,\n project_id,\n realtor_id,\n media,\n property_type,\n property_sale_type,\n country,\n city,\n district,\n price_usd,\n rooms,\n bathrooms,\n area,\n admin_tag,\n time_created,\n last_updated\n) VALUES (\n $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $15\n) RETURNING \n id,\n project_id,\n realtor_id,\n media as \"media: _\",\n property_type as \"property_type: _\",\n property_sale_type as \"property_sale_type: _\",\n country,\n city,\n district,\n price_usd,\n rooms,\n bathrooms,\n area,\n admin_tag,\n time_created,\n last_updated;" + }, + "c571a9279bdcec6420fd1f80d8777832d13e135353a3d40aaf9549c5e80eccab": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "name", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "bio", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "phone_number", + "ordinal": 3, + "type_info": "Varchar" + }, + { + "name": "email", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "profile_picture_url", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "show_projects", + "ordinal": 6, + "type_info": "Bool" + }, + { + "name": "shortcode", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "remax_agent_id", + "ordinal": 8, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 9, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 10, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Varchar", + "Bool", + "Int4", + "Timestamptz" + ] + } + }, + "query": "UPDATE realtor SET\n name = $2,\n bio = $3,\n phone_number = $4,\n email = $5,\n profile_picture_url = $6,\n show_projects = $7,\n remax_agent_id = $8,\n last_updated = $9\nWHERE id = $1\nRETURNING *;" + }, + "e9fb0b1fe0e33d2a8aa4bc20be141a9f4bcd68d1c69af1dce93c43c8ba96ebc1": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "realtor_id", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "clickable: _", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "trackable_id", + "ordinal": 3, + "type_info": "Uuid" + }, + { + "name": "time_created", + "ordinal": 4, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Varchar", + "Uuid", + "Timestamptz" + ] + } + }, + "query": "INSERT INTO click (\n id, realtor_id, clickable, trackable_id, time_created\n) VALUES (\n $1, $2, $3, $4, $5\n) RETURNING \n id,\n realtor_id,\n clickable as \"clickable: _\",\n trackable_id,\n time_created;" + }, + "f0886a67a7e0e9a6582b8852352bc3f7076a89884c5cc653c1399e733578362f": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "who_was", + "ordinal": 1, + "type_info": "Uuid" + }, + { + "name": "ip_address", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "browser_width", + "ordinal": 3, + "type_info": "Int4" + }, + { + "name": "browser_height", + "ordinal": 4, + "type_info": "Int4" + }, + { + "name": "user_agent", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "time_created", + "ordinal": 6, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + true, + false, + false, + false, + false, + false + ], + "parameters": { + "Left": [ + "Text" + ] + } + }, + "query": "SELECT * FROM trackable WHERE ip_address = $1;" + }, + "f7824e34ab77274c6428a02e14dc5b807be14c74f278b96ea311be620bd81608": { + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Uuid" + }, + { + "name": "name", + "ordinal": 1, + "type_info": "Varchar" + }, + { + "name": "bio", + "ordinal": 2, + "type_info": "Varchar" + }, + { + "name": "phone_number", + "ordinal": 3, + "type_info": "Varchar" + }, + { + "name": "email", + "ordinal": 4, + "type_info": "Varchar" + }, + { + "name": "profile_picture_url", + "ordinal": 5, + "type_info": "Varchar" + }, + { + "name": "show_projects", + "ordinal": 6, + "type_info": "Bool" + }, + { + "name": "shortcode", + "ordinal": 7, + "type_info": "Varchar" + }, + { + "name": "remax_agent_id", + "ordinal": 8, + "type_info": "Int4" + }, + { + "name": "time_created", + "ordinal": 9, + "type_info": "Timestamptz" + }, + { + "name": "last_updated", + "ordinal": 10, + "type_info": "Timestamptz" + } + ], + "nullable": [ + false, + false, + false, + false, + true, + false, + false, + false, + true, + false, + false + ], + "parameters": { + "Left": [ + "Uuid" + ] + } + }, + "query": "SELECT * FROM realtor WHERE id = $1;" + } +} \ No newline at end of file diff --git a/src/dao/main_dao.rs b/src/dao/main_dao.rs index e69de29..5d755d5 100644 --- a/src/dao/main_dao.rs +++ b/src/dao/main_dao.rs @@ -0,0 +1,10 @@ +use dotenvy_macro::dotenv; +use sqlx::PgPool; + +pub async fn connect_to_database() -> Result { + let db_url: &str = dotenv!("DATABASE_URL"); + + let formatted_db_url = &format!("{db_url}"); + + sqlx::PgPool::connect(&formatted_db_url).await +} diff --git a/src/dao/mod.rs b/src/dao/mod.rs index 538bf95..1817f85 100644 --- a/src/dao/mod.rs +++ b/src/dao/mod.rs @@ -10,3 +10,5 @@ pub mod realtor; pub mod trackable; #[allow(unused)] pub mod view; + +pub mod main_dao; diff --git a/src/main.rs b/src/main.rs index c578045..0be249e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,29 @@ +use std::sync::Arc; + +use chrono::Utc; +use dao::main_dao; + mod dao; mod routes; mod services; mod utils; #[tokio::main] -async fn main() {} +async fn main() { main_start().await } + +/// Use this, to get autocomplete. As the tokio::main macro messes with the LSP +async fn main_start() { + let start_time = Utc::now().timestamp_millis(); + + let db_conn = Arc::new(match main_dao::connect_to_database().await { + Ok(db_conn) => db_conn, + Err(error) => { + println!("Error connecting with the database: {error}"); + panic!(); + }, + }); + + routes::main_router::start_all_routes(start_time, db_conn) + .await + .unwrap(); +} \ No newline at end of file diff --git a/src/routes/click.rs b/src/routes/click.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/main_router.rs b/src/routes/main_router.rs index 8b13789..8759e1d 100644 --- a/src/routes/main_router.rs +++ b/src/routes/main_router.rs @@ -1 +1,62 @@ +use std::{sync::Arc}; + +use actix_cors::Cors; +use actix_multipart::form::MultipartFormConfig; +use actix_web::{ + web::{self}, + App, HttpServer, +}; +//use actix_web_lab::web::spa; +use chrono::Utc; +use reqwest::Client; +use sqlx::PgPool; + +use crate::utils::s3; + +pub const HOST_ADDR: &str = "0.0.0.0"; +pub const HOST_PORT: u16 = 8080; + +pub async fn start_all_routes(start_time: i64, db_conn: Arc) -> Result<(), std::io::Error> { + let client_state = web::Data::new(Arc::new(Client::new())); + let aws_client = web::Data::new(Arc::new(s3::init_aws_client().await)); + // Start server code that turns into a future to be executed below + let server_future = HttpServer::new(move || { + let cors_policy = Cors::permissive(); + App::new() + .wrap(cors_policy) + .app_data(client_state.clone()) + .app_data(web::Data::new(db_conn.clone())) + .app_data(aws_client.clone()) + .app_data(MultipartFormConfig::default().memory_limit(52_428_800)) + .service( + web::scope("/api") + .service( + web::scope("/admin") + ) + .service( + web::scope("/read") + ) + ) + + /*.service( + spa() + .index_file("./dist/index.html") + .static_resources_mount("/") + .static_resources_location("./dist") + .finish() + )*/ + }) + .bind((HOST_ADDR, HOST_PORT))? + .run(); + + after_startup_fn(start_time); + server_future.await +} + +pub fn after_startup_fn(start_time: i64) { + println!( + "Server took {}ms to setup", + Utc::now().timestamp_millis() - start_time + ); +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index abbbe10..4789e27 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1 +1,7 @@ pub mod main_router; +pub mod click; +pub mod project; +pub mod property; +pub mod realtor; +pub mod trackable; +pub mod view; \ No newline at end of file diff --git a/src/routes/project.rs b/src/routes/project.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/property.rs b/src/routes/property.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/realtor.rs b/src/routes/realtor.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/trackable.rs b/src/routes/trackable.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/view.rs b/src/routes/view.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/services/click.rs b/src/services/click.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/services/mod.rs b/src/services/mod.rs index 8b13789..71f0405 100644 --- a/src/services/mod.rs +++ b/src/services/mod.rs @@ -1 +1,6 @@ - +pub mod click; +pub mod project; +pub mod property; +pub mod realtor; +pub mod trackable; +pub mod view; \ No newline at end of file diff --git a/src/services/property.rs b/src/services/property.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/services/trackable.rs b/src/services/trackable.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/services/view.rs b/src/services/view.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/mod.rs b/src/utils/mod.rs index c21ce77..da8e70c 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,2 +1,4 @@ #[allow(unused)] pub mod macros; +#[allow(unused)] +pub mod s3; \ No newline at end of file diff --git a/src/utils/s3.rs b/src/utils/s3.rs new file mode 100644 index 0000000..3ab41c9 --- /dev/null +++ b/src/utils/s3.rs @@ -0,0 +1,31 @@ +use aws_sdk_s3::{ + error::SdkError, operation::put_object::PutObjectError, primitives::ByteStream, Client, +}; + +pub async fn init_aws_client() -> Client { + dotenvy::dotenv().expect("Failed loading env"); + let config = aws_config::load_from_env().await; + Client::new(&config) +} + +pub async fn upload_image( + client: &Client, + file_name: String, + multipart: Vec, +) -> Result> { + let path = format!("jl-images/{file_name}"); + match client + .put_object() + .bucket("jorge-ledesma-bucket") + .key(path.clone()) + .body(ByteStream::from(multipart)) + .acl(aws_sdk_s3::types::ObjectCannedAcl::PublicRead) + .send() + .await + { + Ok(_) => Ok(format!( + "https://jorge-ledesma-bucket.s3.us-east-2.amazonaws.com/{path}" + )), + Err(error) => Err(error), + } +}