From 10151b234f3490ad62fb75e27e867125c18f4831 Mon Sep 17 00:00:00 2001 From: continuist Date: Wed, 26 Mar 2025 21:26:03 -0400 Subject: [PATCH] First commit --- .gitignore | 1 + backend/.env | 7 + ...8a2bdbaeabbe137a871e26741a419a1aa5b19.json | 14 + ...b0080e0deafd7377a13bd027dc670a7c045b5.json | 40 + ...0d03f33abbe3b549df521a6ae6ad51ac2eadb.json | 38 + ...ee5e31b64ce252b76ff4b66aa77837f37135a.json | 41 + backend/Cargo.lock | 2327 +++++++++++++++++ backend/Cargo.toml | 45 + backend/crates/application/Cargo.toml | 15 + backend/crates/application/src/lib.rs | 2 + .../crates/application/src/services/mod.rs | 1 + .../crates/application/src/services/todo.rs | 68 + backend/crates/application/src/state.rs | 9 + backend/crates/db/Cargo.toml | 22 + backend/crates/db/src/lib.rs | 2 + backend/crates/db/src/models/mod.rs | 1 + backend/crates/db/src/models/todo.rs | 46 + backend/crates/db/src/postgres.rs | 26 + backend/crates/db/src/repositories/mod.rs | 2 + .../crates/db/src/repositories/repository.rs | 37 + backend/crates/db/src/repositories/todo.rs | 106 + backend/crates/domain/Cargo.toml | 14 + backend/crates/domain/src/lib.rs | 3 + backend/crates/domain/src/models/id.rs | 73 + backend/crates/domain/src/models/mod.rs | 13 + backend/crates/domain/src/models/name.rs | 44 + backend/crates/domain/src/models/todo.rs | 77 + backend/crates/domain/src/models/user.rs | 40 + backend/crates/domain/src/repositories/mod.rs | 2 + .../domain/src/repositories/repository.rs | 30 + .../crates/domain/src/repositories/todo.rs | 13 + backend/crates/domain/src/services/mod.rs | 2 + backend/crates/domain/src/services/service.rs | 22 + backend/crates/domain/src/services/todo.rs | 14 + backend/crates/http/Cargo.toml | 21 + backend/crates/http/src/config.rs | 0 backend/crates/http/src/handlers/mod.rs | 1 + .../crates/http/src/handlers/todo/create.rs | 27 + .../http/src/handlers/todo/delete_by_id.rs | 25 + .../crates/http/src/handlers/todo/get_all.rs | 24 + .../http/src/handlers/todo/get_by_id.rs | 26 + backend/crates/http/src/handlers/todo/mod.rs | 5 + .../http/src/handlers/todo/update_by_id.rs | 27 + backend/crates/http/src/lib.rs | 5 + backend/crates/http/src/models/error.rs | 39 + backend/crates/http/src/models/mod.rs | 3 + backend/crates/http/src/models/response.rs | 56 + backend/crates/http/src/models/todo.rs | 52 + backend/crates/http/src/routes.rs | 24 + backend/crates/http/src/server.rs | 62 + backend/crates/infrastructure/Cargo.toml | 25 + backend/crates/infrastructure/src/config.rs | 31 + backend/crates/infrastructure/src/lib.rs | 2 + backend/crates/infrastructure/src/web.rs | 29 + .../migrations/20241219150755_init.down.sql | 2 + backend/migrations/20241219150755_init.up.sql | 7 + backend/src/bin/web.rs | 7 + 57 files changed, 3697 insertions(+) create mode 100644 .gitignore create mode 100644 backend/.env create mode 100644 backend/.sqlx/query-183ad1d8316ef2ae5ac6ae4811b8a2bdbaeabbe137a871e26741a419a1aa5b19.json create mode 100644 backend/.sqlx/query-3adb46818539e755dc942a3e66ab0080e0deafd7377a13bd027dc670a7c045b5.json create mode 100644 backend/.sqlx/query-9c2f662465a7c8db8fa17a2002c0d03f33abbe3b549df521a6ae6ad51ac2eadb.json create mode 100644 backend/.sqlx/query-fe4b98cadd468fd286a85771507ee5e31b64ce252b76ff4b66aa77837f37135a.json create mode 100644 backend/Cargo.lock create mode 100644 backend/Cargo.toml create mode 100644 backend/crates/application/Cargo.toml create mode 100644 backend/crates/application/src/lib.rs create mode 100644 backend/crates/application/src/services/mod.rs create mode 100644 backend/crates/application/src/services/todo.rs create mode 100644 backend/crates/application/src/state.rs create mode 100644 backend/crates/db/Cargo.toml create mode 100644 backend/crates/db/src/lib.rs create mode 100644 backend/crates/db/src/models/mod.rs create mode 100644 backend/crates/db/src/models/todo.rs create mode 100644 backend/crates/db/src/postgres.rs create mode 100644 backend/crates/db/src/repositories/mod.rs create mode 100644 backend/crates/db/src/repositories/repository.rs create mode 100644 backend/crates/db/src/repositories/todo.rs create mode 100644 backend/crates/domain/Cargo.toml create mode 100644 backend/crates/domain/src/lib.rs create mode 100644 backend/crates/domain/src/models/id.rs create mode 100644 backend/crates/domain/src/models/mod.rs create mode 100644 backend/crates/domain/src/models/name.rs create mode 100644 backend/crates/domain/src/models/todo.rs create mode 100644 backend/crates/domain/src/models/user.rs create mode 100644 backend/crates/domain/src/repositories/mod.rs create mode 100644 backend/crates/domain/src/repositories/repository.rs create mode 100644 backend/crates/domain/src/repositories/todo.rs create mode 100644 backend/crates/domain/src/services/mod.rs create mode 100644 backend/crates/domain/src/services/service.rs create mode 100644 backend/crates/domain/src/services/todo.rs create mode 100644 backend/crates/http/Cargo.toml create mode 100644 backend/crates/http/src/config.rs create mode 100644 backend/crates/http/src/handlers/mod.rs create mode 100644 backend/crates/http/src/handlers/todo/create.rs create mode 100644 backend/crates/http/src/handlers/todo/delete_by_id.rs create mode 100644 backend/crates/http/src/handlers/todo/get_all.rs create mode 100644 backend/crates/http/src/handlers/todo/get_by_id.rs create mode 100644 backend/crates/http/src/handlers/todo/mod.rs create mode 100644 backend/crates/http/src/handlers/todo/update_by_id.rs create mode 100644 backend/crates/http/src/lib.rs create mode 100644 backend/crates/http/src/models/error.rs create mode 100644 backend/crates/http/src/models/mod.rs create mode 100644 backend/crates/http/src/models/response.rs create mode 100644 backend/crates/http/src/models/todo.rs create mode 100644 backend/crates/http/src/routes.rs create mode 100644 backend/crates/http/src/server.rs create mode 100644 backend/crates/infrastructure/Cargo.toml create mode 100644 backend/crates/infrastructure/src/config.rs create mode 100644 backend/crates/infrastructure/src/lib.rs create mode 100644 backend/crates/infrastructure/src/web.rs create mode 100644 backend/migrations/20241219150755_init.down.sql create mode 100644 backend/migrations/20241219150755_init.up.sql create mode 100644 backend/src/bin/web.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9b6841 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +backend/target \ No newline at end of file diff --git a/backend/.env b/backend/.env new file mode 100644 index 0000000..41b2344 --- /dev/null +++ b/backend/.env @@ -0,0 +1,7 @@ +DATABASE_URL="postgres://postgres:password@localhost:5432/pylon" + +# The lowest level of log event to be recorded. +RUST_LOG="debug" + +# The port on which the server should listen for requests. +SERVER_PORT="8080" diff --git a/backend/.sqlx/query-183ad1d8316ef2ae5ac6ae4811b8a2bdbaeabbe137a871e26741a419a1aa5b19.json b/backend/.sqlx/query-183ad1d8316ef2ae5ac6ae4811b8a2bdbaeabbe137a871e26741a419a1aa5b19.json new file mode 100644 index 0000000..fb994d1 --- /dev/null +++ b/backend/.sqlx/query-183ad1d8316ef2ae5ac6ae4811b8a2bdbaeabbe137a871e26741a419a1aa5b19.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM todos WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "183ad1d8316ef2ae5ac6ae4811b8a2bdbaeabbe137a871e26741a419a1aa5b19" +} diff --git a/backend/.sqlx/query-3adb46818539e755dc942a3e66ab0080e0deafd7377a13bd027dc670a7c045b5.json b/backend/.sqlx/query-3adb46818539e755dc942a3e66ab0080e0deafd7377a13bd027dc670a7c045b5.json new file mode 100644 index 0000000..8a791e1 --- /dev/null +++ b/backend/.sqlx/query-3adb46818539e755dc942a3e66ab0080e0deafd7377a13bd027dc670a7c045b5.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id, title, description, completed FROM todos WHERE id = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "description", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "completed", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3adb46818539e755dc942a3e66ab0080e0deafd7377a13bd027dc670a7c045b5" +} diff --git a/backend/.sqlx/query-9c2f662465a7c8db8fa17a2002c0d03f33abbe3b549df521a6ae6ad51ac2eadb.json b/backend/.sqlx/query-9c2f662465a7c8db8fa17a2002c0d03f33abbe3b549df521a6ae6ad51ac2eadb.json new file mode 100644 index 0000000..0818fc3 --- /dev/null +++ b/backend/.sqlx/query-9c2f662465a7c8db8fa17a2002c0d03f33abbe3b549df521a6ae6ad51ac2eadb.json @@ -0,0 +1,38 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM todos ORDER BY id", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "description", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "completed", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "9c2f662465a7c8db8fa17a2002c0d03f33abbe3b549df521a6ae6ad51ac2eadb" +} diff --git a/backend/.sqlx/query-fe4b98cadd468fd286a85771507ee5e31b64ce252b76ff4b66aa77837f37135a.json b/backend/.sqlx/query-fe4b98cadd468fd286a85771507ee5e31b64ce252b76ff4b66aa77837f37135a.json new file mode 100644 index 0000000..8fbe28b --- /dev/null +++ b/backend/.sqlx/query-fe4b98cadd468fd286a85771507ee5e31b64ce252b76ff4b66aa77837f37135a.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO todos\n (title, description)\n VALUES ($1, $2)\n RETURNING id, title, description, completed", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "description", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "completed", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "fe4b98cadd468fd286a85771507ee5e31b64ce252b76ff4b66aa77837f37135a" +} diff --git a/backend/Cargo.lock b/backend/Cargo.lock new file mode 100644 index 0000000..b8c3bd9 --- /dev/null +++ b/backend/Cargo.lock @@ -0,0 +1,2327 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" + +[[package]] +name = "application" +version = "0.0.0" +dependencies = [ + "anyhow", + "async-trait", + "domain", + "thiserror", +] + +[[package]] +name = "async-trait" +version = "0.1.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d556ec1359574147ec0c4fc5eb525f3f23263a592b1a9c07e0a75b427de55c97" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +dependencies = [ + "serde", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + +[[package]] +name = "cc" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "db" +version = "0.0.0" +dependencies = [ + "anyhow", + "async-trait", + "domain", + "serde", + "sqlx", + "uuid", +] + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "domain" +version = "0.0.0" +dependencies = [ + "anyhow", + "async-trait", + "serde", + "thiserror", + "uuid", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +dependencies = [ + "serde", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "http" +version = "0.0.0" +dependencies = [ + "anyhow", + "application", + "axum", + "domain", + "serde", + "serde_json", + "thiserror", + "tokio", + "tower-http", + "tracing", +] + +[[package]] +name = "http" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.2.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.2.0", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-util", + "http 1.2.0", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +dependencies = [ + "equivalent", + "hashbrown 0.15.2", +] + +[[package]] +name = "infrastructure" +version = "0.0.0" +dependencies = [ + "anyhow", + "application", + "db", + "dotenvy", + "http 0.0.0", + "sqlx", + "thiserror", + "tokio", +] + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "libc" +version = "0.2.168" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" + +[[package]] +name = "libm" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "new-stack-backend" +version = "0.0.0" +dependencies = [ + "anyhow", + "infrastructure", + "tokio", +] + +[[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 = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "0.38.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.216" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlformat" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bba3a93db0cc4f7bdece8bb09e77e2e785c20bfebf79eb8340ed80708048790" +dependencies = [ + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93334716a037193fac19df402f8571269c84a00852f6a7066b5d2616dcd64d3e" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d8060b456358185f7d50c55d9b5066ad956956fddec42ee2e8567134a8936e" +dependencies = [ + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.14.5", + "hashlink", + "hex", + "indexmap", + "log", + "memchr", + "native-tls", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cac0692bcc9de3b073e8d747391827297e075c7710ff6276d9f7a1f3d58c6657" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1804e8a7c7865599c9c79be146dc8a9fd8cc86935fa641d3ea58e5f0688abaa5" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5b2cf34a45953bfd3daaf3db0f7a7878ab9b7a6b91b422d24a7a9e4c857b680" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[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-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "bitflags", + "bytes", + "http 1.2.0", + "http-body", + "http-body-util", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" + +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +dependencies = [ + "getrandom", + "rand", + "serde", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "whoami" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372d5b87f58ec45c384ba03563b03544dc5fadc3983e434b286913f5b4a9bb6d" +dependencies = [ + "redox_syscall", + "wasite", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "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.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/backend/Cargo.toml b/backend/Cargo.toml new file mode 100644 index 0000000..7c6d648 --- /dev/null +++ b/backend/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "new-stack-backend" +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[[bin]] +name = "web" +path = "src/bin/web.rs" + +[workspace] +members = [ + "crates/domain", + "crates/application", + "crates/db", + "crates/http", + "crates/infrastructure" +] + +[workspace.package] +authors = ["Richard K. Schultz "] +version = "0.0.0" +edition = "2021" +rust-version = "1.81.0" + +[dependencies] +infrastructure = "=0.0.0" + +anyhow = "1.0.94" +tokio = { version = "1.40", features = ["full"] } + +[patch.crates-io] +db = { path = "crates/db" } +http = { path = "crates/http" } +application = { path = "crates/application" } +domain = { path = "crates/domain" } +infrastructure = { path = "crates/infrastructure" } + +[profile.release] +lto = true +opt-level = 3 +codegen-units = 1 +strip = true diff --git a/backend/crates/application/Cargo.toml b/backend/crates/application/Cargo.toml new file mode 100644 index 0000000..1ff0ef3 --- /dev/null +++ b/backend/crates/application/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "application" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] +# Workspace dependencies +domain = "=0.0.0" + +# External dependencies +anyhow = "1.0.94" +async-trait = "0.1.58" +thiserror = "1.0" diff --git a/backend/crates/application/src/lib.rs b/backend/crates/application/src/lib.rs new file mode 100644 index 0000000..ee2fe2b --- /dev/null +++ b/backend/crates/application/src/lib.rs @@ -0,0 +1,2 @@ +pub mod services; +pub mod state; diff --git a/backend/crates/application/src/services/mod.rs b/backend/crates/application/src/services/mod.rs new file mode 100644 index 0000000..ff6eb8e --- /dev/null +++ b/backend/crates/application/src/services/mod.rs @@ -0,0 +1 @@ +pub mod todo; diff --git a/backend/crates/application/src/services/todo.rs b/backend/crates/application/src/services/todo.rs new file mode 100644 index 0000000..ac29bcc --- /dev/null +++ b/backend/crates/application/src/services/todo.rs @@ -0,0 +1,68 @@ +use domain::services::service::ServiceError; +use domain::models::todo::{CreateTodo, Todo}; +use domain::repositories::repository::ResultPaging; +use domain::repositories::todo::TodoRepository; +use domain::services::service::ServiceResult; +use domain::services::todo::TodoService; +use domain::models::Id; + +#[derive(Clone)] +pub struct TodoServiceImpl +where + R: TodoRepository +{ + pub repository: R +} + +impl TodoServiceImpl +where + R: TodoRepository +{ + pub fn new(repository: R) -> Self { + Self { + repository + } + } +} + +impl TodoService for TodoServiceImpl +where + R: TodoRepository +{ + async fn create(&self, create_todo: CreateTodo) -> ServiceResult { + let mut cloned = create_todo.clone(); + self.repository + .create(&mut cloned) + .await + .map_err(|e| -> ServiceError { e.into() }) + } + + async fn list(&self) -> ServiceResult> { + self.repository + .list() + .await + .map_err(|e| -> ServiceError { e.into() }) + } + + async fn get(&self, id: Id) -> ServiceResult { + self.repository + .get(id) + .await + .map_err(|e| -> ServiceError { e.into() }) + } + + async fn delete(&self, id: Id) -> ServiceResult<()> { + self.repository + .delete(id) + .await + .map_err(|e| -> ServiceError { e.into() }) + } + + async fn update(&self, todo: Todo) -> ServiceResult { + let mut cloned = todo.clone(); + self.repository + .update(&mut cloned) + .await + .map_err(|e| -> ServiceError { e.into() }) + } +} diff --git a/backend/crates/application/src/state.rs b/backend/crates/application/src/state.rs new file mode 100644 index 0000000..54a3bd5 --- /dev/null +++ b/backend/crates/application/src/state.rs @@ -0,0 +1,9 @@ +use std::sync::Arc; + +use domain::services::todo::TodoService; + +/// The global application state shared between all request handlers. +#[derive(Debug, Clone)] +pub struct AppState { + pub todo_service: Arc, +} diff --git a/backend/crates/db/Cargo.toml b/backend/crates/db/Cargo.toml new file mode 100644 index 0000000..7577231 --- /dev/null +++ b/backend/crates/db/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "db" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] +# Workspace dependencies +domain = "=0.0.0" + +# External dependencies +anyhow = "1.0.94" +async-trait = "0.1.58" +serde = { version = "1", features = ["std", "derive"] } +sqlx = { version = "0.8.2", default-features = false, features = [ + "runtime-tokio-native-tls", + "macros", + "postgres", + "uuid", +] } +uuid = { version = "1.11.0", features = ["v7", "fast-rng", "serde"] } diff --git a/backend/crates/db/src/lib.rs b/backend/crates/db/src/lib.rs new file mode 100644 index 0000000..3888bb6 --- /dev/null +++ b/backend/crates/db/src/lib.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod repositories; diff --git a/backend/crates/db/src/models/mod.rs b/backend/crates/db/src/models/mod.rs new file mode 100644 index 0000000..ff6eb8e --- /dev/null +++ b/backend/crates/db/src/models/mod.rs @@ -0,0 +1 @@ +pub mod todo; diff --git a/backend/crates/db/src/models/todo.rs b/backend/crates/db/src/models/todo.rs new file mode 100644 index 0000000..e1f0f9c --- /dev/null +++ b/backend/crates/db/src/models/todo.rs @@ -0,0 +1,46 @@ +use domain::models::todo::{CreateTodo, Todo}; + +pub struct TodoPostgres { + pub id: uuid::Uuid, + pub title: String, + pub description: String, + pub completed: bool, +} + +// Factory method for creating a new TodoPostgres from a Todo +impl From for TodoPostgres { + fn from(t: Todo) -> Self { + TodoPostgres { + id: t.id.id(), + title: t.title, + description: t.description, + completed: t.completed, + } + } +} + +pub struct CreateTodoPostgres { + pub title: String, + pub description: String, +} + +// Factory method for creating a new Todo from a TodoPostgres +impl Into for TodoPostgres { + fn into(self) -> Todo { + Todo { + id: self.id.into(), + title: self.title, + description: self.description, + completed: self.completed, + } + } +} + +impl From for CreateTodoPostgres { + fn from(t: CreateTodo) -> Self { + CreateTodoPostgres { + title: t.title, + description: t.description, + } + } +} \ No newline at end of file diff --git a/backend/crates/db/src/postgres.rs b/backend/crates/db/src/postgres.rs new file mode 100644 index 0000000..464032c --- /dev/null +++ b/backend/crates/db/src/postgres.rs @@ -0,0 +1,26 @@ +use sqlx::PgPool; + +pub type DBConn = PgPool; + +const UNIQUE_CONSTRAINT_VIOLATION_CODE: &str = "2067"; + +fn is_unique_constraint_violation(err: &sqlx::Error) -> bool { + if let sqlx::Error::Database(db_err) = err { + if let Some(code) = db_err.code() { + if code == UNIQUE_CONSTRAINT_VIOLATION_CODE { + return true; + } + } + } + + false +} + +fn is_row_not_found_error(err: &sqlx::Error) -> bool { + if let sqlx::Error::RowNotFound = err { + return true; + } + + false +} + diff --git a/backend/crates/db/src/repositories/mod.rs b/backend/crates/db/src/repositories/mod.rs new file mode 100644 index 0000000..67838b0 --- /dev/null +++ b/backend/crates/db/src/repositories/mod.rs @@ -0,0 +1,2 @@ +pub mod repository; +pub mod todo; diff --git a/backend/crates/db/src/repositories/repository.rs b/backend/crates/db/src/repositories/repository.rs new file mode 100644 index 0000000..8641ae5 --- /dev/null +++ b/backend/crates/db/src/repositories/repository.rs @@ -0,0 +1,37 @@ +use domain::repositories::repository::{RepositoryError, RepositoryObject, RepositoryOperation}; + +#[derive(Debug)] +pub struct PostgresRepositoryError(RepositoryError); + +impl PostgresRepositoryError { + pub fn into_inner(self) -> RepositoryError { + self.0 + } +} + +impl From<(sqlx::Error, RepositoryOperation, RepositoryObject)> for PostgresRepositoryError { + fn from(error_tuple: (sqlx::Error, RepositoryOperation, RepositoryObject)) -> PostgresRepositoryError { + + let operation = match error_tuple.1 { + RepositoryOperation::Create => "create", + RepositoryOperation::GetOne => "get", + RepositoryOperation::GetMany => "list", + RepositoryOperation::Update => "update", + RepositoryOperation::Delete => "delete" + }; + + let object = match error_tuple.2 { + RepositoryObject::Todo => "Todo" + }; + + let message = format!("Could not {} {}: {}", operation, object, error_tuple.0); + + PostgresRepositoryError( + RepositoryError { + operation: error_tuple.1, + object: error_tuple.2, + message: message.to_string(), + } + ) + } +} \ No newline at end of file diff --git a/backend/crates/db/src/repositories/todo.rs b/backend/crates/db/src/repositories/todo.rs new file mode 100644 index 0000000..1bced10 --- /dev/null +++ b/backend/crates/db/src/repositories/todo.rs @@ -0,0 +1,106 @@ +use std::sync::Arc; + +use sqlx::PgPool; + +use domain::models::todo::{CreateTodo, Todo}; +use domain::repositories::repository::{RepositoryResult, ResultPaging, RepositoryOperation, RepositoryObject}; +use domain::repositories::todo::TodoRepository; +use domain::models::Id; +use crate::repositories::repository::PostgresRepositoryError; + +#[derive(Clone)] +pub struct TodoPostgresRepository { + pub pool: Arc +} + + +impl TodoPostgresRepository { + pub fn new(pool: Arc) -> Self { + TodoPostgresRepository { pool } + } +} + +impl TodoRepository for TodoPostgresRepository { + + async fn create(&self, new_todo: &CreateTodo) -> RepositoryResult { + let title = &new_todo.title(); + let description = &new_todo.description(); + let record = sqlx::query_as!(Todo, + r#"INSERT INTO todos + (title, description) + VALUES ($1, $2) + RETURNING id, title, description, completed"#, + title, + description + ).fetch_one(&*self.pool) + .await + .map_err(|v| PostgresRepositoryError::from((v, RepositoryOperation::Create, RepositoryObject::Todo)).into_inner())?; + + Ok(record) + } + + async fn list(&self) -> RepositoryResult> { + let records = sqlx::query_as!(Todo, + "SELECT * FROM todos ORDER BY id" + ).fetch_all(&*self.pool) + .await + .map_err(|v| PostgresRepositoryError::from((v, RepositoryOperation::GetMany, RepositoryObject::Todo)).into_inner())?; + + Ok(ResultPaging { + total: records.len().try_into().unwrap(), + items: records.into_iter().map(|v| v.into()).collect() + }) + } + + async fn get(&self, id: Id) -> RepositoryResult { + let id = id.id(); + let record = sqlx::query_as!(Todo, + "SELECT id, title, description, completed FROM todos WHERE id = $1", + id + ).fetch_one(&*self.pool) + .await + .map_err(|v| PostgresRepositoryError::from((v, RepositoryOperation::GetOne, RepositoryObject::Todo)).into_inner())?; + + Ok(record) + } + + async fn delete(&self, id: Id) -> RepositoryResult<()> { + let id = id.id(); + let _ = sqlx::query_as!(Todo, + "DELETE FROM todos WHERE id = $1", + id + ).execute(&*self.pool) + .await + .map_err(|v| PostgresRepositoryError::from((v, RepositoryOperation::Delete, RepositoryObject::Todo)).into_inner())?; + + Ok(()) + } + + async fn update(&self, todo: &Todo) -> RepositoryResult { + let id = todo.id().id(); + let title = todo.title(); + let description = todo.description(); + let completed = todo.completed(); + let record = sqlx::query_as!( + Todo, + r#"--sql + with update_todo as ( + update todos + set title = $2, description = $3, completed = $4 + where id = $1 + returning id, title, description, completed + ) + select * from update_todo + "#, + id, + title, + description, + completed + ).fetch_one(&*self.pool) + .await + .map_err(|v| PostgresRepositoryError::from((v, RepositoryOperation::Update, RepositoryObject::Todo)).into_inner())?; + + Ok(record) + } + +} diff --git a/backend/crates/domain/Cargo.toml b/backend/crates/domain/Cargo.toml new file mode 100644 index 0000000..5ff3042 --- /dev/null +++ b/backend/crates/domain/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "domain" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] +# External dependencies +anyhow = "1.0.86" +async-trait = "0.1.58" +uuid = { version = "1.11.0", features = ["v7", "fast-rng"] } +serde = { version = "1.0", features = ["derive"] } +thiserror = "1.0" diff --git a/backend/crates/domain/src/lib.rs b/backend/crates/domain/src/lib.rs new file mode 100644 index 0000000..94137e7 --- /dev/null +++ b/backend/crates/domain/src/lib.rs @@ -0,0 +1,3 @@ +pub mod models; +pub mod repositories; +pub mod services; \ No newline at end of file diff --git a/backend/crates/domain/src/models/id.rs b/backend/crates/domain/src/models/id.rs new file mode 100644 index 0000000..268df77 --- /dev/null +++ b/backend/crates/domain/src/models/id.rs @@ -0,0 +1,73 @@ +//! A generalised ID type for entities and aggregates. + +use std::fmt; +use std::fmt::Display; +use serde::Serialize; + +#[derive(Debug, Serialize)] +pub struct Id(uuid::Uuid); + +#[derive(Debug, Clone)] +pub struct IdParseError {} + +impl Id { + pub fn new() -> Self { + Self { + 0: uuid::Uuid::now_v7(), + } + } + + pub fn from_string(from: String) -> Result { + uuid::Uuid::parse_str(from.as_str()) + .map_err(|_| IdParseError {}) + .map(|val| Self { + 0: val + }) + } + + pub fn to_string(self) -> String { + self.0.to_string() + } + + pub fn id(self) -> uuid::Uuid { + self.0 + } +} + +impl From for Id { + fn from(uuid: uuid::Uuid) -> Self { + Self { 0: uuid } + } +} + +impl Clone for Id { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for Id {} + +impl PartialEq for Id { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Display for Id { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn format_id() { + let uuid_value = uuid::Uuid::now_v7(); + let id = Id::from_string(uuid_value.to_string()).expect(""); + assert_eq!(format!("{id}"), uuid_value.to_string()); + } +} diff --git a/backend/crates/domain/src/models/mod.rs b/backend/crates/domain/src/models/mod.rs new file mode 100644 index 0000000..907ef51 --- /dev/null +++ b/backend/crates/domain/src/models/mod.rs @@ -0,0 +1,13 @@ +// Value objects +mod id; +mod name; + +// Entities +pub mod todo; + +// pub use self::id::{Id, IdParseError}; +// pub use self::name::{Name, NameError}; +// pub use self::todo::{InvalidTodoError, Todo}; + +pub use self::id::*; +pub use self::name::*; diff --git a/backend/crates/domain/src/models/name.rs b/backend/crates/domain/src/models/name.rs new file mode 100644 index 0000000..731175b --- /dev/null +++ b/backend/crates/domain/src/models/name.rs @@ -0,0 +1,44 @@ +use std::fmt; +use std::fmt::{Display, Formatter}; +use thiserror::Error; + +const MAX_COUNT: usize = 128; + +#[derive(Debug, Clone, PartialEq)] +pub struct Name(String); + +#[derive(Error, Debug, Clone, PartialEq)] +pub enum NameError { + #[error("input cannot be empty")] + Empty, + #[error("input length ({0}) exceeds maximum {}", MAX_COUNT)] + TooLong(usize), +} + +impl Name { + pub fn new(raw: &str) -> Result { + let len = raw.chars().count(); + if len == 0 { + return Err(NameError::Empty); + } else if len > MAX_COUNT { + return Err(NameError::TooLong(len)); + } + Ok(Self(raw.into())) + } + + pub fn into_string(self) -> String { + self.0 + } +} + +impl AsRef for Name { + fn as_ref(&self) -> &str { + &self.0 + } +} + +impl Display for Name { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} diff --git a/backend/crates/domain/src/models/todo.rs b/backend/crates/domain/src/models/todo.rs new file mode 100644 index 0000000..02127c9 --- /dev/null +++ b/backend/crates/domain/src/models/todo.rs @@ -0,0 +1,77 @@ +use crate::models::{Id, IdParseError}; +use serde::Serialize; +use thiserror::Error; + +#[derive(Clone, Serialize)] +pub struct Todo { + pub id: Id, + pub title: String, + pub description: String, + pub completed: bool, +} + +#[derive(Clone)] +pub struct CreateTodo { + pub title: String, + pub description: String, +} + +#[derive(Error, Debug)] +pub enum InvalidCreateTodoError { + #[error("title parse error")] + Title, + #[error("description parse error")] + Description, +} + +#[derive(Error, Debug)] +pub enum InvalidTodoError { + #[error("id parse error")] + Id +} + +impl Todo { + + pub fn new(id: Id, title: String, description: String, completed: bool) -> Self { + Self { id, title, description, completed } + } + + pub fn id(&self) -> Id { + self.id.clone() + } + + pub fn title(&self) -> String { + self.title.clone() + } + + pub fn description(&self) -> String { + self.description.clone() + } + + pub fn completed(&self) -> bool { + self.completed + } + +} + +impl CreateTodo { + + pub fn new(title: String, description: String) -> Self { + Self { title, description } + } + + pub fn title(&self) -> String { + self.title.clone() + } + + pub fn description(&self) -> String { + self.description.clone() + } + +} + +impl From for InvalidTodoError { + fn from(_: IdParseError) -> Self { + InvalidTodoError::Id + } +} diff --git a/backend/crates/domain/src/models/user.rs b/backend/crates/domain/src/models/user.rs new file mode 100644 index 0000000..59e9b8b --- /dev/null +++ b/backend/crates/domain/src/models/user.rs @@ -0,0 +1,40 @@ +use crate::{Id, IdParseError, Name, NameError}; +use thiserror::Error; + +#[derive(Debug, Clone)] +pub struct User { + id: Id, + first_name: Name, + last_name: Name, +} + +#[derive(Error, Debug)] +pub enum InvalidUserError { + #[error("uuid parse error")] + Id(IdParseError), + #[error(transparent)] + Name(#[from] NameError), +} + +impl User { + #[must_use] + pub fn new(id: Id, first_name: Name, last_name: Name) -> Self { + Self { + id, + first_name, + last_name, + } + } + #[must_use] + pub const fn id(&self) -> Id { + self.id + } + #[must_use] + pub fn first_name(&self) -> String { + self.first_name.to_string() + } + #[must_use] + pub fn last_name(&self) -> String { + self.last_name.to_string() + } +} diff --git a/backend/crates/domain/src/repositories/mod.rs b/backend/crates/domain/src/repositories/mod.rs new file mode 100644 index 0000000..76b4675 --- /dev/null +++ b/backend/crates/domain/src/repositories/mod.rs @@ -0,0 +1,2 @@ +pub mod todo; +pub mod repository; diff --git a/backend/crates/domain/src/repositories/repository.rs b/backend/crates/domain/src/repositories/repository.rs new file mode 100644 index 0000000..32ed28e --- /dev/null +++ b/backend/crates/domain/src/repositories/repository.rs @@ -0,0 +1,30 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug)] +pub enum RepositoryOperation { + Create, + GetOne, + GetMany, + Update, + Delete +} + +#[derive(Debug)] +pub enum RepositoryObject { + Todo +} + +#[derive(Debug)] +pub struct RepositoryError { + pub operation: RepositoryOperation, + pub object: RepositoryObject, + pub message: String, +} + +pub type RepositoryResult = Result; + +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] +pub struct ResultPaging { + pub total: u64, + pub items: Vec, +} diff --git a/backend/crates/domain/src/repositories/todo.rs b/backend/crates/domain/src/repositories/todo.rs new file mode 100644 index 0000000..c87e86d --- /dev/null +++ b/backend/crates/domain/src/repositories/todo.rs @@ -0,0 +1,13 @@ +use std::future::Future; + +use crate::repositories::repository::{ResultPaging, RepositoryResult}; +use crate::models::todo::{Todo, CreateTodo}; +use crate::models::Id; + +pub trait TodoRepository: Clone + Send + Sync + 'static { + fn create(self: &Self, new_todo: &CreateTodo) -> impl Future> + Send; + fn list(self: &Self) -> impl Future>> + Send; + fn get(self: &Self, id: Id) -> impl Future> + Send; + fn delete(self: &Self, id: Id) -> impl Future> + Send; + fn update(self: &Self, todo: &Todo) -> impl Future> + Send; +} \ No newline at end of file diff --git a/backend/crates/domain/src/services/mod.rs b/backend/crates/domain/src/services/mod.rs new file mode 100644 index 0000000..f656781 --- /dev/null +++ b/backend/crates/domain/src/services/mod.rs @@ -0,0 +1,2 @@ +pub mod service; +pub mod todo; diff --git a/backend/crates/domain/src/services/service.rs b/backend/crates/domain/src/services/service.rs new file mode 100644 index 0000000..0031f74 --- /dev/null +++ b/backend/crates/domain/src/services/service.rs @@ -0,0 +1,22 @@ +use crate::repositories::repository::RepositoryError; + +#[derive(Debug)] +pub struct ServiceError { + pub message: String, +} + +pub type ServiceResult = Result; + +impl std::fmt::Display for ServiceError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.message) + } +} + +impl Into for RepositoryError { + fn into(self) -> ServiceError { + ServiceError { + message: self.message + } + } +} \ No newline at end of file diff --git a/backend/crates/domain/src/services/todo.rs b/backend/crates/domain/src/services/todo.rs new file mode 100644 index 0000000..1ecd392 --- /dev/null +++ b/backend/crates/domain/src/services/todo.rs @@ -0,0 +1,14 @@ +use std::future::Future; + +use crate::models::Id; +use crate::services::service::ServiceResult; +use crate::models::todo::{CreateTodo, Todo}; +use crate::repositories::repository::ResultPaging; + +pub trait TodoService: Send + Sync + Clone + 'static { + fn create(&self, todo: CreateTodo) -> impl Future> + Send; + fn list(&self) -> impl Future>> + Send; + fn get(&self, id: Id) -> impl Future> + Send; + fn delete(&self, id: Id) -> impl Future> + Send; + fn update(&self, todo: Todo) -> impl Future> + Send; +} \ No newline at end of file diff --git a/backend/crates/http/Cargo.toml b/backend/crates/http/Cargo.toml new file mode 100644 index 0000000..d100afd --- /dev/null +++ b/backend/crates/http/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "http" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] +# Workspace dependencies +application = "=0.0.0" +domain = "=0.0.0" + +anyhow = "1.0.86" +axum = { version = "0.7.5", features = ["macros"] } +#axum-macros = { version = "0.5.0" } +serde = { version = "1", features = ["std", "derive"] } +serde_json = "1.0.128" +thiserror = "1.0" +tokio = { version = "1.38", features = ["full"] } +tower-http = { version = "0.5.2", features = ["trace"] } +tracing = "0.1.40" diff --git a/backend/crates/http/src/config.rs b/backend/crates/http/src/config.rs new file mode 100644 index 0000000..e69de29 diff --git a/backend/crates/http/src/handlers/mod.rs b/backend/crates/http/src/handlers/mod.rs new file mode 100644 index 0000000..ff6eb8e --- /dev/null +++ b/backend/crates/http/src/handlers/mod.rs @@ -0,0 +1 @@ +pub mod todo; diff --git a/backend/crates/http/src/handlers/todo/create.rs b/backend/crates/http/src/handlers/todo/create.rs new file mode 100644 index 0000000..fb15ba1 --- /dev/null +++ b/backend/crates/http/src/handlers/todo/create.rs @@ -0,0 +1,27 @@ +use axum::extract::State; +use axum::Json; + +use application::state::AppState; +use domain::models::todo::Todo; +use domain::services::todo::TodoService; +use crate::models::error::HttpError; +use crate::models::response::HttpGetOneResponse; +use crate::models::todo::HttpCreateTodoRequest; + +/// Create a new [Todo]. +/// +/// # Responses +/// +/// - 201 Created: the [Todo] was successfully created. +/// - 422 Unprocessable entity: An [Todo] with the same name already exists. +pub async fn create( + State(state): State>, + Json(req): Json, +) -> Result, HttpError> { + + state.todo_service + .create(req.into()) + .await + .map_err(|e| e.into()) + .map(|todo: Todo| todo.into()) +} diff --git a/backend/crates/http/src/handlers/todo/delete_by_id.rs b/backend/crates/http/src/handlers/todo/delete_by_id.rs new file mode 100644 index 0000000..77187b5 --- /dev/null +++ b/backend/crates/http/src/handlers/todo/delete_by_id.rs @@ -0,0 +1,25 @@ +use axum::extract::{Path, State}; + +use application::state::AppState; +use domain::models::Id; +use domain::services::todo::TodoService; +use crate::models::error::HttpError; + +/// Create a new [Todo]. +/// +/// # Responses +/// +/// - 201 Created: the [Todo] was successfully created. +/// - 422 Unprocessable entity: An [Todo] with the same name already exists. +pub async fn delete_by_id( + State(state): State>, + Path(id): Path, +) -> Result<(), HttpError> { + + state.todo_service + .delete(Id::from_string(id)?) + .await + .map_err(|e| e.into()) + .map(|_| ()) + +} diff --git a/backend/crates/http/src/handlers/todo/get_all.rs b/backend/crates/http/src/handlers/todo/get_all.rs new file mode 100644 index 0000000..f3aee66 --- /dev/null +++ b/backend/crates/http/src/handlers/todo/get_all.rs @@ -0,0 +1,24 @@ +use axum::extract::State; + +use application::state::AppState; +use domain::models::todo::Todo; +use domain::services::todo::TodoService; +use crate::models::error::HttpError; +use crate::models::response::HttpGetManyResponse; + +/// Get all [Todo]s. +/// +/// # Responses +/// +/// - 201 Created: the [Todo] was successfully created. +/// - 422 Unprocessable entity: An [Todo] with the same name already exists. +pub async fn get_all( + State(state): State> +) -> Result, HttpError> { + + state.todo_service + .list() + .await + .map_err(|e| e.into()) + .map(|result| result.into()) +} diff --git a/backend/crates/http/src/handlers/todo/get_by_id.rs b/backend/crates/http/src/handlers/todo/get_by_id.rs new file mode 100644 index 0000000..06e488b --- /dev/null +++ b/backend/crates/http/src/handlers/todo/get_by_id.rs @@ -0,0 +1,26 @@ +use axum::extract::{Path, State}; + +use application::state::AppState; +use domain::models::Id; +use domain::models::todo::Todo; +use domain::services::todo::TodoService; +use crate::models::error::HttpError; +use crate::models::response::HttpGetOneResponse; + +/// Create a new [Todo]. +/// +/// # Responses +/// +/// - 201 Created: the [Todo] was successfully created. +/// - 422 Unprocessable entity: An [Todo] with the same name already exists. +pub async fn get_by_id( + State(state): State>, + Path(id): Path, +) -> Result, HttpError> { + + state.todo_service + .get(Id::from_string(id)?) + .await + .map_err(|e| e.into()) + .map(|todo: Todo| todo.into()) +} diff --git a/backend/crates/http/src/handlers/todo/mod.rs b/backend/crates/http/src/handlers/todo/mod.rs new file mode 100644 index 0000000..08fe0e7 --- /dev/null +++ b/backend/crates/http/src/handlers/todo/mod.rs @@ -0,0 +1,5 @@ +pub mod create; +pub mod delete_by_id; +pub mod get_all; +pub mod get_by_id; +pub mod update_by_id; diff --git a/backend/crates/http/src/handlers/todo/update_by_id.rs b/backend/crates/http/src/handlers/todo/update_by_id.rs new file mode 100644 index 0000000..63d4644 --- /dev/null +++ b/backend/crates/http/src/handlers/todo/update_by_id.rs @@ -0,0 +1,27 @@ +use axum::extract::State; +use axum::Json; + +use application::state::AppState; +use domain::models::todo::Todo; +use domain::services::todo::TodoService; +use crate::models::error::HttpError; +use crate::models::response::HttpGetOneResponse; +use crate::models::todo::HttpTodoRequest; + +/// Update an existing [Todo]. +/// +/// # Responses +/// +/// - 201 Created: the [Todo] was successfully updated. +/// - 422 Unprocessable entity: An [Todo] with the same name already exists. +pub async fn update_by_id( + State(state): State>, + Json(req): Json, +) -> Result, HttpError> { + + state.todo_service + .update(req.try_into()?) + .await + .map_err(|e| e.into()) + .map(|todo: Todo| todo.into()) +} diff --git a/backend/crates/http/src/lib.rs b/backend/crates/http/src/lib.rs new file mode 100644 index 0000000..f3552a6 --- /dev/null +++ b/backend/crates/http/src/lib.rs @@ -0,0 +1,5 @@ +pub mod config; +pub mod handlers; +pub mod models; +pub mod routes; +pub mod server; diff --git a/backend/crates/http/src/models/error.rs b/backend/crates/http/src/models/error.rs new file mode 100644 index 0000000..bea8ef5 --- /dev/null +++ b/backend/crates/http/src/models/error.rs @@ -0,0 +1,39 @@ +use serde::Serialize; +use serde_json::json; +use axum::Json; +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; + +use domain::models::IdParseError; +use domain::services::service::ServiceError; + +/// The response body data field for an unsuccessful request. +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct HttpError { + pub message: String +} + +impl From for HttpError { + fn from(from: ServiceError) -> Self { + Self { + message: from.message + } + } +} + +/// Converts a [IdParseError] into a [HttpError] +impl From for HttpError { + fn from(_: IdParseError) -> Self { + Self { + message: "Not a valid ID".to_string() + } + } +} + +impl IntoResponse for HttpError { + fn into_response(self) -> Response { + let http_status_code = StatusCode::INTERNAL_SERVER_ERROR; + let body = Json(json!({"message": self.message })); + (http_status_code, body).into_response() + } +} \ No newline at end of file diff --git a/backend/crates/http/src/models/mod.rs b/backend/crates/http/src/models/mod.rs new file mode 100644 index 0000000..9e5b8b0 --- /dev/null +++ b/backend/crates/http/src/models/mod.rs @@ -0,0 +1,3 @@ +pub mod error; +pub mod response; +pub mod todo; diff --git a/backend/crates/http/src/models/response.rs b/backend/crates/http/src/models/response.rs new file mode 100644 index 0000000..4e91cd9 --- /dev/null +++ b/backend/crates/http/src/models/response.rs @@ -0,0 +1,56 @@ +use serde::Serialize; +use serde_json::json; +use axum::Json; +use axum::http::StatusCode; +use axum::response::{IntoResponse, Response}; + +use domain::repositories::repository::ResultPaging; + +/// The response body data field for successful response for GET API calls that expect one item to be returned +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct HttpGetOneResponse(T); + +impl From for HttpGetOneResponse { + fn from(from: T) -> Self { + Self { + 0: from + } + } +} + +impl IntoResponse for HttpGetOneResponse +where + T: Serialize +{ + fn into_response(self) -> Response { + let http_status_code = StatusCode::FOUND; + let body = Json(json!({"data": self })); + (http_status_code, body).into_response() + } +} + +/// Get Many Response +/// + +/// The response body data field for successful response for GET API calls that expect lists of many items to be returned +#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +pub struct HttpGetManyResponse(ResultPaging); + +impl From> for HttpGetManyResponse { + fn from(from: ResultPaging) -> Self { + Self { + 0: from + } + } +} + +impl IntoResponse for HttpGetManyResponse +where + T: Serialize +{ + fn into_response(self) -> Response { + let http_status_code = StatusCode::FOUND; + let body = Json(json!({"data": self })); + (http_status_code, body).into_response() + } +} \ No newline at end of file diff --git a/backend/crates/http/src/models/todo.rs b/backend/crates/http/src/models/todo.rs new file mode 100644 index 0000000..2602332 --- /dev/null +++ b/backend/crates/http/src/models/todo.rs @@ -0,0 +1,52 @@ +use serde::Deserialize; + +use crate::models::error::HttpError; +use domain::models::Id; +use domain::models::todo::{CreateTodo, Todo}; + +/// Create Request +/// + +/// The body of an [Todo] creation request. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] +pub struct HttpCreateTodoRequest { + pub title: String, + pub description: String +} + +/// Converts a [CreateTodoHttpRequest] request into a domain [CreateTodo] request +impl From for CreateTodo { + fn from(req: HttpCreateTodoRequest) -> Self { + Self { + title: req.title, + description: req.description + } + } +} + +/// Update Request +/// + +/// The body of an [Todo] update request. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] +pub struct HttpTodoRequest { + pub id: String, + pub title: String, + pub description: String, + pub completed: bool +} + +/// Converts a [UpdateTodoHttpRequest] request into a domain [Todo] request +impl TryFrom for Todo { + type Error = HttpError; + fn try_from(req: HttpTodoRequest) -> Result { + Id::from_string(req.id) + .map_err(|e| e.into()) + .map(|id| Todo { + id, + title: req.title, + description: req.description, + completed: req.completed + }) + } +} diff --git a/backend/crates/http/src/routes.rs b/backend/crates/http/src/routes.rs new file mode 100644 index 0000000..c22b5b2 --- /dev/null +++ b/backend/crates/http/src/routes.rs @@ -0,0 +1,24 @@ +use crate::handlers::todo::create::create; +use crate::handlers::todo::get_by_id::get_by_id; +use crate::handlers::todo::get_all::get_all; +use crate::handlers::todo::delete_by_id::delete_by_id; +use crate::handlers::todo::update_by_id::update_by_id; +use application::state::AppState; +use axum::routing::get; +use axum::Router; +use domain::services::todo::TodoService; + +pub fn api_routes() -> Router> { + Router::new() + .route( + "/todos", + get(get_all::) + .post(create::) + .patch(update_by_id::) + ) + .route( + "/todos/:id", + get(get_by_id::) + .delete(delete_by_id::), + ) +} diff --git a/backend/crates/http/src/server.rs b/backend/crates/http/src/server.rs new file mode 100644 index 0000000..ae8ab02 --- /dev/null +++ b/backend/crates/http/src/server.rs @@ -0,0 +1,62 @@ +use std::sync::Arc; + +use anyhow::Context; +use domain::services::todo::TodoService; +use tokio::net; +use application::state::AppState; + +use crate::routes::api_routes; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct HttpServerConfig<'a> { + pub port: &'a str, +} + + +pub struct HttpServer { + router: axum::Router, + listener: net::TcpListener, +} + +impl HttpServer { + /// Returns a new HTTP server bound to the port specified in `config`. + pub async fn new( + todo_service: impl TodoService, + config: HttpServerConfig<'_>, + ) -> anyhow::Result { + let trace_layer = tower_http::trace::TraceLayer::new_for_http().make_span_with( + |request: &axum::extract::Request<_>| { + let uri = request.uri().to_string(); + tracing::info_span!("http_request", method = ?request.method(), uri) + }, + ); + + // Construct dependencies to inject into handlers. + let state = AppState { + todo_service: Arc::new(todo_service), + }; + + let router = axum::Router::new() + .nest("/api", api_routes()) + .layer(trace_layer) + .with_state(state); + + let listener = net::TcpListener::bind(format!("0.0.0.0:{}", config.port)) + .await + .with_context(|| format!("failed to listen on {}", config.port))?; + + Ok(Self { router, listener }) + } + + /// Runs the HTTP server. + pub async fn run(self) -> anyhow::Result<()> { + tracing::debug!("listening on {}", self.listener.local_addr().unwrap()); + + axum::serve(self.listener, self.router) + .await + .context("received error from running server")?; + + Ok(()) + } + +} diff --git a/backend/crates/infrastructure/Cargo.toml b/backend/crates/infrastructure/Cargo.toml new file mode 100644 index 0000000..0c93789 --- /dev/null +++ b/backend/crates/infrastructure/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "infrastructure" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +publish = false + +[dependencies] + +# Workspace dependencies +application = "=0.0.0" +db = "=0.0.0" +http = "=0.0.0" + +# External dependencies +anyhow = "1.0.94" +dotenvy = "0.15.7" +sqlx = { version = "0.8.2", default-features = false, features = [ + "runtime-tokio-native-tls", + "macros", + "postgres", + "uuid", +] } +thiserror = "1.0" +tokio = { version = "1.40", features = ["full"] } \ No newline at end of file diff --git a/backend/crates/infrastructure/src/config.rs b/backend/crates/infrastructure/src/config.rs new file mode 100644 index 0000000..bd0d3b6 --- /dev/null +++ b/backend/crates/infrastructure/src/config.rs @@ -0,0 +1,31 @@ +use std::env; + +use anyhow::Context; + +const DATABASE_URL_KEY: &str = "DATABASE_URL"; + +const SERVER_PORT_KEY: &str = "SERVER_PORT"; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Config { + pub server_port: String, + pub database_url: String, +} + +impl Config { + pub fn from_env() -> anyhow::Result { + dotenvy::dotenv().ok(); + + let server_port = load_env(SERVER_PORT_KEY)?; + let database_url = load_env(DATABASE_URL_KEY)?; + + Ok(Config { + server_port, + database_url, + }) + } +} + +fn load_env(key: &str) -> anyhow::Result { + env::var(key).with_context(|| format!("failed to load environment variable {}", key)) +} diff --git a/backend/crates/infrastructure/src/lib.rs b/backend/crates/infrastructure/src/lib.rs new file mode 100644 index 0000000..9d25402 --- /dev/null +++ b/backend/crates/infrastructure/src/lib.rs @@ -0,0 +1,2 @@ +pub mod config; +pub mod web; \ No newline at end of file diff --git a/backend/crates/infrastructure/src/web.rs b/backend/crates/infrastructure/src/web.rs new file mode 100644 index 0000000..bdabedc --- /dev/null +++ b/backend/crates/infrastructure/src/web.rs @@ -0,0 +1,29 @@ +use std::sync::Arc; + +use sqlx::postgres::PgPoolOptions; + +use crate::config::Config; +use db::repositories::todo::TodoPostgresRepository; +use application::services::todo::TodoServiceImpl; +use http::server::{HttpServer, HttpServerConfig}; + +pub async fn run() -> anyhow::Result<()> { + + let config = Config::from_env()?; + + let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set"); + + let pool = PgPoolOptions::new().connect(&db_url).await?; + + let db = Arc::new(pool); + + let todo_repository = TodoPostgresRepository::new(db); + let todo_service = TodoServiceImpl::new(todo_repository); + + let server_config = HttpServerConfig { + port: &config.server_port, + }; + let http_server = HttpServer::new(todo_service, server_config).await?; + http_server.run().await + +} \ No newline at end of file diff --git a/backend/migrations/20241219150755_init.down.sql b/backend/migrations/20241219150755_init.down.sql new file mode 100644 index 0000000..719941f --- /dev/null +++ b/backend/migrations/20241219150755_init.down.sql @@ -0,0 +1,2 @@ +-- Add down migration script here +DROP TABLE IF EXISTS todos; diff --git a/backend/migrations/20241219150755_init.up.sql b/backend/migrations/20241219150755_init.up.sql new file mode 100644 index 0000000..1b2bded --- /dev/null +++ b/backend/migrations/20241219150755_init.up.sql @@ -0,0 +1,7 @@ +-- Add up migration script here +CREATE TABLE IF NOT EXISTS todos ( + id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v7(), + title TEXT UNIQUE NOT NULL, + description TEXT NOT NULL, + completed BOOLEAN NOT NULL DEFAULT FALSE +); diff --git a/backend/src/bin/web.rs b/backend/src/bin/web.rs new file mode 100644 index 0000000..ca95e83 --- /dev/null +++ b/backend/src/bin/web.rs @@ -0,0 +1,7 @@ +use infrastructure::web; + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + web::run().await +} +