From e6a011f159230054a3f38078bc7a4169d23a9cdc Mon Sep 17 00:00:00 2001 From: Peter Schiwy Date: Tue, 17 Dec 2024 14:23:27 +0100 Subject: [PATCH] =?UTF-8?q?kleine=20=C3=84nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env_dev | 10 +++- .sqlfluff | 18 +++++++ Cargo.lock | 124 ++++++++++++++++++++++++------------------------ Cargo.toml | 18 +++---- src/database.rs | 3 +- 5 files changed, 99 insertions(+), 74 deletions(-) create mode 100644 .sqlfluff diff --git a/.env_dev b/.env_dev index 5261425..6ba0900 100644 --- a/.env_dev +++ b/.env_dev @@ -1,4 +1,10 @@ -HOST=0.0.0.0 -PORT=8080 +HTTP_PORT=8080 +HTTP_HOST=0.0.0.0. + DATABASE_URL="postgres://user:password@server:port/database" +DATABASE_POOLSIZE=32 +DATABASE_MAX_LIFETIME= + +GRAPHQL_SCHEMA_LOCATION="tests/schema.graphql" + RUST_LOG=info,actix=info diff --git a/.sqlfluff b/.sqlfluff new file mode 100644 index 0000000..1ed0ec4 --- /dev/null +++ b/.sqlfluff @@ -0,0 +1,18 @@ +[sqlfluff] +dialect = postgres +templater = jinja +sql_file_exts = .sql,.sql.j2,.dml,.ddl + +[sqlfluff:indentation] +indented_joins = True +indented_using_on = True +template_blocks_indent = False + +[sqlfluff:templater] +unwrap_wrapped_queries = True + +[sqlfluff:templater:jinja] +apply_dbt_builtins = True + +[sqlfluff:rules:capitalisation.keywords] +capitalisation_policy = upper diff --git a/Cargo.lock b/Cargo.lock index 5a4c127..2c50410 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -120,22 +120,22 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "async-graphql" -version = "7.0.11" +version = "7.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba6d24703c5adc5ba9116901b92ee4e4c0643c01a56c4fd303f3818638d7449" +checksum = "59fd6bd734afb8b6e4d0f84a3e77305ce0a7ccc60d70f6001cb5e1c3f38d8ff1" dependencies = [ "async-graphql-derive", "async-graphql-parser", "async-graphql-value", "async-stream", "async-trait", - "base64 0.22.1", + "base64", "bytes", "chrono", "fnv", @@ -149,7 +149,6 @@ dependencies = [ "mime", "multer", "num-traits", - "once_cell", "pin-project-lite", "regex", "serde", @@ -162,9 +161,9 @@ dependencies = [ [[package]] name = "async-graphql-axum" -version = "7.0.11" +version = "7.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aa80e171205c6d562057fd5a49167c8fbe61f7db2bed6540f6d4f2234d7ff2" +checksum = "ec8c1bb47161c37286e40e2fa58055e97b2a2b6cf1022a6686967e10636fa5d7" dependencies = [ "async-graphql", "async-trait", @@ -180,9 +179,9 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "7.0.11" +version = "7.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c2d176893486bd37cd1b6defadd999f7357bf5804e92f510c08bcf16c538f" +checksum = "ac38b4dd452d529d6c0248b51df23603f0a875770352e26ae8c346ce6c149b3e" dependencies = [ "Inflector", "async-graphql-parser", @@ -197,9 +196,9 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "7.0.11" +version = "7.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79272bdbf26af97866e149f05b2b546edb5c00e51b5f916289931ed233e208ad" +checksum = "42d271ddda2f55b13970928abbcbc3423cfc18187c60e8769b48f21a93b7adaa" dependencies = [ "async-graphql-value", "pest", @@ -209,9 +208,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "7.0.11" +version = "7.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5ec94176a12a8cbe985cd73f2e54dc9c702c88c766bdef12f1f3a67cedbee1" +checksum = "aefe909173a037eaf3281b046dc22580b59a38b765d7b8d5116f2ffef098048d" dependencies = [ "bytes", "indexmap", @@ -269,14 +268,14 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", "axum-macros", - "base64 0.21.7", + "base64", "bytes", "futures-util", "http", @@ -296,10 +295,10 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.1", + "sync_wrapper", "tokio", "tokio-tungstenite", - "tower", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -331,9 +330,9 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", @@ -344,7 +343,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper", "tower-layer", "tower-service", "tracing", @@ -352,11 +351,10 @@ dependencies = [ [[package]] name = "axum-macros" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" +checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" dependencies = [ - "heck 0.4.1", "proc-macro2", "quote", "syn", @@ -377,12 +375,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -457,9 +449,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -680,9 +672,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06676b12debf7bba6903559720abca942d3a66b8acb88815fd2c7c6537e9ade1" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -1072,6 +1064,8 @@ dependencies = [ "hyper", "pin-project-lite", "tokio", + "tower 0.4.13", + "tower-service", ] [[package]] @@ -1839,18 +1833,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -2102,7 +2096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" dependencies = [ "atoi", - "base64 0.22.1", + "base64", "bitflags 2.5.0", "byteorder", "bytes", @@ -2146,7 +2140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" dependencies = [ "atoi", - "base64 0.22.1", + "base64", "bitflags 2.5.0", "byteorder", "chrono", @@ -2266,12 +2260,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.1" @@ -2368,9 +2356,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -2406,9 +2394,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.21.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", @@ -2460,20 +2448,35 @@ dependencies = [ "tokio", "tower-layer", "tower-service", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", "tracing", ] [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -2533,9 +2536,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "chrono", "matchers", @@ -2552,9 +2555,9 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.21.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" dependencies = [ "byteorder", "bytes", @@ -2565,7 +2568,6 @@ dependencies = [ "rand", "sha1", "thiserror", - "url", "utf-8", ] diff --git a/Cargo.toml b/Cargo.toml index 419301c..da45e90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -async-graphql = { version = "7.0.11", default-features = false, features = [ +async-graphql = { version = "7.0.13", default-features = false, features = [ "chrono", "uuid", 'dataloader', @@ -12,7 +12,7 @@ async-graphql = { version = "7.0.11", default-features = false, features = [ 'graphiql', 'playground', ] } -axum = { version = "0.7.5", features = ["macros"] } +axum = { version = "0.7.9", features = ["macros"] } sqlx = { version = "0.8.2", features = [ "runtime-tokio-native-tls", "uuid", @@ -20,15 +20,15 @@ sqlx = { version = "0.8.2", features = [ "chrono", "macros", ] } -anyhow = "1.0.86" -async-graphql-axum = "7.0.11" -chrono = { version = "0.4.38", features = ["serde"] } +anyhow = "1.0.94" +async-graphql-axum = "7.0.13" +chrono = { version = "0.4.39", features = ["serde"] } dotenv = "0.15.0" envy = "0.4.2" -env_logger = "0.11.4" +env_logger = "0.11.5" log = "0.4.22" -serde = "1.0.215" -tokio = { version = "1.39.1", features = ["macros", "rt-multi-thread"] } +serde = "1.0.216" +tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] } # UUID uuid = { version = "1.11.0", features = ["serde", "v4", "macro-diagnostics"] } @@ -36,7 +36,7 @@ ulid = { version = "1.1.3", features = ["uuid"] } # Logging tracing = "0.1.41" -tracing-subscriber = { version = "0.3.18", features = ["env-filter", "chrono"] } +tracing-subscriber = { version = "0.3.19", features = ["env-filter", "chrono"] } tracing-appender = "0.2.3" itertools = "0.13.0" diff --git a/src/database.rs b/src/database.rs index 349687d..960de13 100644 --- a/src/database.rs +++ b/src/database.rs @@ -8,8 +8,7 @@ use crate::config; pub type DB = Pool; pub trait Queryer<'c>: Executor<'c, Database = sqlx::Postgres> {} -// impl<'c> Queryer<'c> for &Pool {} -impl<'c> Queryer<'c> for &DB {} +impl Queryer<'_> for &DB {} pub async fn connect(database: &config::Database) -> Result { PgPoolOptions::new()