diff --git a/examples/loco_example/Cargo.lock b/examples/loco_example/Cargo.lock index 2dc5ff0f9..b42854ad8 100644 --- a/examples/loco_example/Cargo.lock +++ b/examples/loco_example/Cargo.lock @@ -56,6 +56,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "allocator-api2" version = "0.2.16" @@ -93,9 +108,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -183,6 +198,22 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "async-compression" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c" +dependencies = [ + "brotli", + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", + "zstd", + "zstd-safe", +] + [[package]] name = "async-executor" version = "1.8.0" @@ -245,7 +276,7 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.3.2", + "polling 3.4.0", "rustix 0.38.31", "slab", "tracing", @@ -394,6 +425,7 @@ checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", + "axum-macros", "bytes", "futures-util", "http 1.0.0", @@ -441,6 +473,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum-extra" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "895ff42f72016617773af68fb90da2a9677d89c62338ec09162d4909d86fdd8f" +dependencies = [ + "axum", + "axum-core", + "bytes", + "cookie", + "futures-util", + "http 1.0.0", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "serde", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c055ee2d014ae5981ce1016374e8213682aa14d9bf40e48ab48b5f3ef20eaa" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "axum-test" version = "14.3.0" @@ -618,6 +684,27 @@ dependencies = [ "syn_derive", ] +[[package]] +name = "brotli" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bstr" version = "1.9.0" @@ -722,6 +809,7 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -887,6 +975,7 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8" dependencies = [ + "percent-encoding", "time", "version_check", ] @@ -921,6 +1010,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "cron_clock" version = "0.8.0" @@ -1235,6 +1333,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "flume" version = "0.11.0" @@ -1558,9 +1666,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -1861,7 +1969,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", "windows-sys 0.48.0", ] @@ -1881,6 +1989,15 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.67" @@ -2017,17 +2134,18 @@ dependencies = [ [[package]] name = "loco-rs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af486e72ce8e7f6a8ae87bab477131db2b1b819f7f76ff4583f69207cc783f48" +version = "0.2.3" +source = "git+https://github.com/billy1624/loco?branch=sea-orm-v1.0#50b5e14273b4f4ceb60af5cfc4ecba8ae2cc214d" dependencies = [ "argon2", "async-trait", "axum", + "axum-extra", "axum-test", "backtrace_printer", "bb8", "byte-unit", + "bytes", "cargo_metadata", "cfg-if", "chrono", @@ -2036,10 +2154,13 @@ dependencies = [ "duct", "eyre", "fs-err", + "futures-util", + "hyper", "include_dir", "jsonwebtoken", "lazy_static", "lettre", + "mime", "rand", "regex", "requestty", @@ -2054,6 +2175,7 @@ dependencies = [ "tera", "thiserror", "tokio", + "tower", "tower-http", "tracing", "tracing-subscriber", @@ -2261,7 +2383,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", ] @@ -2589,9 +2711,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", @@ -3214,7 +3336,7 @@ dependencies = [ [[package]] name = "sea-orm" -version = "0.12.12" +version = "1.0.0-rc.1" dependencies = [ "async-stream", "async-trait", @@ -3240,7 +3362,7 @@ dependencies = [ [[package]] name = "sea-orm-cli" -version = "0.12.12" +version = "1.0.0-rc.1" dependencies = [ "chrono", "clap", @@ -3255,7 +3377,7 @@ dependencies = [ [[package]] name = "sea-orm-macros" -version = "0.12.12" +version = "1.0.0-rc.1" dependencies = [ "heck", "proc-macro2", @@ -3267,7 +3389,7 @@ dependencies = [ [[package]] name = "sea-orm-migration" -version = "0.12.12" +version = "1.0.0-rc.1" dependencies = [ "async-trait", "clap", @@ -4019,13 +4141,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall", "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -4281,8 +4402,10 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0da193277a4e2c33e59e09b5861580c33dd0a637c3883d0fa74ba40c0374af2e" dependencies = [ + "async-compression", "bitflags 2.4.2", "bytes", + "futures-core", "futures-util", "http 1.0.0", "http-body", @@ -4990,3 +5113,31 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zstd" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.9+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/examples/loco_example/Cargo.toml b/examples/loco_example/Cargo.toml index 0b15c9df3..36e75b301 100644 --- a/examples/loco_example/Cargo.toml +++ b/examples/loco_example/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] -loco-rs = { version = "=0.1.7" } +loco-rs = { version = "0.2" } migration = { path = "migration" } serde = { version = "1", features = ["derive"] } @@ -43,7 +43,7 @@ required-features = [] [dev-dependencies] serial_test = "2.0.0" rstest = "0.18.2" -loco-rs = { version = "0.1.7", features = ["testing"] } +loco-rs = { version = "0.2", features = ["testing"] } insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] } # This allows us to develop using a local version of sea-orm @@ -51,3 +51,4 @@ insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] } [patch.crates-io] sea-orm = { path = "../../" } sea-orm-migration = { path = "../../sea-orm-migration" } +loco-rs = { git = "https://github.com/billy1624/loco", branch = "sea-orm-v1.0" } diff --git a/examples/loco_example/migration/Cargo.toml b/examples/loco_example/migration/Cargo.toml index a6d944b56..47e4ab55a 100644 --- a/examples/loco_example/migration/Cargo.toml +++ b/examples/loco_example/migration/Cargo.toml @@ -10,7 +10,7 @@ path = "src/lib.rs" [dependencies] async-std = { version = "1", features = ["attributes", "tokio1"] } -loco-rs = { version = "=0.1.7" } +loco-rs = { version = "0.2" } [dependencies.sea-orm-migration] # path = "../../../sea-orm-migration" # remove this line in your own project diff --git a/examples/loco_example/src/app.rs b/examples/loco_example/src/app.rs index f927c50d9..4192d406d 100644 --- a/examples/loco_example/src/app.rs +++ b/examples/loco_example/src/app.rs @@ -3,12 +3,15 @@ use std::path::Path; use async_trait::async_trait; use loco_rs::{ app::{AppContext, Hooks}, + boot::{create_app, BootResult, StartMode}, controller::AppRoutes, db::{self, truncate_table}, + environment::Environment, task::Tasks, worker::Processor, Result, }; +use migration::Migrator; use sea_orm::DatabaseConnection; use crate::{controllers, models::_entities::notes}; @@ -20,7 +23,11 @@ impl Hooks for App { env!("CARGO_CRATE_NAME") } - fn routes() -> AppRoutes { + async fn boot(mode: StartMode, environment: &Environment) -> Result { + create_app::(mode, environment).await + } + + fn routes(_ctx: &AppContext) -> AppRoutes { AppRoutes::with_default_routes() .prefix("/api") .add_route(controllers::notes::routes())