From 9a8341949cc6856148de07f57ab906a349751e9e Mon Sep 17 00:00:00 2001 From: Denux Date: Sat, 11 Jan 2025 16:55:30 +0100 Subject: [PATCH] Some config and dep stuff --- backend/.env.dist | 5 + backend/Cargo.lock | 202 +++++++++++++++++++---- backend/Cargo.toml | 3 +- backend/config/development.yaml | 8 + backend/src/app.rs | 8 +- backend/src/services/instance_handler.rs | 4 +- 6 files changed, 190 insertions(+), 40 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index 04988a64..470b444f 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -12,6 +12,11 @@ TIMEOUT_REQUEST=5000 # External host EXTERNAL_HOST=http://localhost:8080 +# GoCardless integraion +GO_CARDLESS_ENABLED=false +GO_CARDLESS_SECRET_ID= +GO_CARDLESS_SECRET_KEY= + # Database POSTGRES_HOST=127.0.0.1 POSTGRES_PORT=5432 diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 57705907..b79d9cf1 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -462,9 +462,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" dependencies = [ "serde", ] @@ -617,9 +617,9 @@ checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "cc" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a" dependencies = [ "jobserver", "libc", @@ -687,9 +687,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.24" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" +checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" dependencies = [ "clap_builder", "clap_derive", @@ -697,9 +697,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.24" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" +checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" dependencies = [ "anstream", "anstyle", @@ -1258,6 +1258,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +dependencies = [ + "serde", + "typeid", +] + [[package]] name = "errno" version = "0.3.10" @@ -2189,15 +2199,6 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.14" @@ -2367,8 +2368,9 @@ checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" [[package]] name = "loco-gen" -version = "0.13.2" -source = "git+https://github.com/loco-rs/loco?branch=master#f72a6bd6e4091e3bfe3786322d3820dfe912a80c" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef868bd2df99c949018850b36fb700bba01b10001715f94390bcdb81f412f874" dependencies = [ "chrono", "clap", @@ -2386,8 +2388,9 @@ dependencies = [ [[package]] name = "loco-rs" -version = "0.13.2" -source = "git+https://github.com/loco-rs/loco?branch=master#f72a6bd6e4091e3bfe3786322d3820dfe912a80c" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2250c89f0f996c3493ec3d2588a2d63e2861a48df7b9585cb28fbf6faf15a1a0" dependencies = [ "argon2", "async-trait", @@ -2450,9 +2453,12 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "3d6ea2a48c204030ee31a7d7fc72c93294c92fe87ecb1789881c9543516e1a0d" +dependencies = [ + "value-bag", +] [[package]] name = "loom" @@ -2769,9 +2775,9 @@ dependencies = [ [[package]] name = "ouroboros" -version = "0.18.4" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "944fa20996a25aded6b4795c6d63f10014a7a83f8be9828a11860b08c5fc4a67" +checksum = "1e0f050db9c44b97a94723127e6be766ac5c340c48f2c4bb3ffa11713744be59" dependencies = [ "aliasable", "ouroboros_macro", @@ -2780,12 +2786,11 @@ dependencies = [ [[package]] name = "ouroboros_macro" -version = "0.18.4" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39b0deead1528fd0e5947a8546a9642a9777c25f6e1e26f34c97b204bbb465bd" +checksum = "3c7028bdd3d43083f6d8d4d5187680d0d3560d54df4cc9d752005268b41e64d0" dependencies = [ "heck 0.4.1", - "itertools", "proc-macro2", "proc-macro2-diagnostics", "quote", @@ -3631,9 +3636,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" dependencies = [ "log", "once_cell", @@ -3976,6 +3981,15 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "serde_fmt" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4" +dependencies = [ + "serde", +] + [[package]] name = "serde_json" version = "1.0.135" @@ -4579,6 +4593,84 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "sval" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6dc0f9830c49db20e73273ffae9b5240f63c42e515af1da1fceefb69fceafd8" + +[[package]] +name = "sval_buffer" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "429922f7ad43c0ef8fd7309e14d750e38899e32eb7e8da656ea169dd28ee212f" +dependencies = [ + "sval", + "sval_ref", +] + +[[package]] +name = "sval_dynamic" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f16ff5d839396c11a30019b659b0976348f3803db0626f736764c473b50ff4" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_fmt" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c01c27a80b6151b0557f9ccbe89c11db571dc5f68113690c1e028d7e974bae94" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_json" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0deef63c70da622b2a8069d8600cf4b05396459e665862e7bdb290fd6cf3f155" +dependencies = [ + "itoa", + "ryu", + "sval", +] + +[[package]] +name = "sval_nested" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39ce5976ae1feb814c35d290cf7cf8cd4f045782fe1548d6bc32e21f6156e9f" +dependencies = [ + "sval", + "sval_buffer", + "sval_ref", +] + +[[package]] +name = "sval_ref" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb7c6ee3751795a728bc9316a092023529ffea1783499afbc5c66f5fabebb1fa" +dependencies = [ + "sval", +] + +[[package]] +name = "sval_serde" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a5572d0321b68109a343634e3a5d576bf131b82180c6c442dee06349dfc652a" +dependencies = [ + "serde", + "sval", + "sval_nested", +] + [[package]] name = "syn" version = "1.0.109" @@ -5110,6 +5202,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typeid" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" + [[package]] name = "typenum" version = "1.17.0" @@ -5375,9 +5473,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +checksum = "b913a3b5fe84142e269d63cc62b64319ccaf89b748fc31fe025177f767a756c4" dependencies = [ "getrandom", "rand", @@ -5420,6 +5518,42 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "value-bag" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" +dependencies = [ + "value-bag-serde1", + "value-bag-sval2", +] + +[[package]] +name = "value-bag-serde1" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb773bd36fd59c7ca6e336c94454d9c66386416734817927ac93d81cb3c5b0b" +dependencies = [ + "erased-serde", + "serde", + "serde_fmt", +] + +[[package]] +name = "value-bag-sval2" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a916a702cac43a88694c97657d449775667bcd14b70419441d05b7fea4a83a" +dependencies = [ + "sval", + "sval_buffer", + "sval_dynamic", + "sval_fmt", + "sval_json", + "sval_ref", + "sval_serde", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -5857,9 +5991,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.22" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 3369f397..28eb64a2 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -28,8 +28,7 @@ non_ascii_idents = "forbid" ignored = ["include_dir"] [workspace.dependencies] -#loco-rs = { version = "0.14.0", features = ["with-db", "cache_inmem"] } -loco-rs = { git = "https://github.com/loco-rs/loco", branch = "master", features = ["with-db", "cache_inmem"] } +loco-rs = { version = "0.14.0", features = ["with-db", "cache_inmem"] } financrr_macros = { path = "financrr_macros" } [dependencies] diff --git a/backend/config/development.yaml b/backend/config/development.yaml index f036048b..e04981d8 100644 --- a/backend/config/development.yaml +++ b/backend/config/development.yaml @@ -93,3 +93,11 @@ database: dangerously_truncate: false # Recreating schema when application loaded. This is a dangerous operation, make sure that you're using this flag only on dev environments or test mode dangerously_recreate: false + +bank_account_linking: + enabled: true + implementations: + - !GoCardless + enabled: {{get_env(name="GO_CARDLESS_ENABLED", default=false)}} + secret_id: {{get_env(name="GO_CARDLESS_SECRET_ID", default="")}} + secret_key: {{get_env(name="GO_CARDLESS_SECRET_KEY", default="")}} diff --git a/backend/src/app.rs b/backend/src/app.rs index 4b01fe29..0fe4042b 100644 --- a/backend/src/app.rs +++ b/backend/src/app.rs @@ -27,6 +27,8 @@ use loco_rs::{ use migration::Migrator; use mimalloc::MiMalloc; use std::path::Path; +use tracing::{debug, info}; +use crate::services::instance_handler::InstanceHandlerInner; #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; @@ -71,7 +73,11 @@ impl Hooks for App { async fn before_run(ctx: &AppContext) -> Result<()> { // Load and parse CustomConfig - let _ = CustomConfigInner::get_arc(ctx).await?; + let conf = CustomConfigInner::get_arc(ctx).await?; + debug!("Bank account linking configured: {}", conf.is_bank_account_linking_configured()); + + let instance_handler = InstanceHandlerInner::get_arc(ctx).await?; + info!("Instance started with id: {}", instance_handler.get_instance_id()); Ok(()) } diff --git a/backend/src/services/instance_handler.rs b/backend/src/services/instance_handler.rs index 6e24fdea..7f4c0dd0 100644 --- a/backend/src/services/instance_handler.rs +++ b/backend/src/services/instance_handler.rs @@ -8,7 +8,7 @@ use std::process::abort; use std::sync::{Arc, OnceLock}; use std::time::Duration; use tokio_cron_scheduler::{Job, JobScheduler, JobSchedulerError}; -use tracing::{error, info}; +use tracing::error; pub const INSTANCE_HEARTBEAT_INTERVAL_SECONDS: u64 = 10; pub const INSTANCE_HEARTBEAT_TOLERANCE_SECONDS: u64 = INSTANCE_HEARTBEAT_INTERVAL_SECONDS * 3; @@ -36,8 +36,6 @@ impl Service for InstanceHandlerInner { .await .map_err(|err| Error::Any(err.into()))?; - info!("Instance handler started with node id: {}", handler.get_instance_id()); - Ok(handler) }