Skip to content

Commit

Permalink
refactor: change + embed deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Oct 22, 2024
1 parent 482259e commit 14b3f48
Show file tree
Hide file tree
Showing 43 changed files with 109 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ serde = "1"
serde_json = "1"
lazy_static = "1.4.0"
async-trait = { version = "0.1.74" }
axum = { version = "0.7.5", features = ["macros"] }
axum = { version = "0.7.5", features = ["macros", "multipart"] }
tower = "0.4"
tower-http = { version = "0.6.1", features = [
"trace",
Expand Down
7 changes: 0 additions & 7 deletions examples/demo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,13 @@ migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1.33.0", features = ["full"] }
async-trait = "0.1.74"
tracing = "0.1.40"
chrono = "0.4"

sea-orm = { version = "1.1.0", default-features = false, features = ["macros"] }
validator = { version = "0.18" }
sea-orm = { version = "1.1.0", features = [
"sqlx-sqlite",
"sqlx-postgres",
"runtime-tokio-rustls",
"macros",
] }

axum = { version = "0.7.5", features = ["multipart"] }
include_dir = "0.7.3"

axum_session = { version = "0.10.1", default-features = false }
axum-extra = { version = "0.9", features = ["cookie"] }

include_dir = "0.7"
uuid = { version = "1.6.0", features = ["v4"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }

fluent-templates = { version = "0.8.0", features = ["tera"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/examples/playground.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::app::App;
#[allow(unused_imports)]
use loco_rs::{cli::playground, prelude::*};
use loco_rs::{cli::playground, prelude::*, tokio};

#[tokio::main]
async fn main() -> loco_rs::Result<()> {
Expand Down
1 change: 1 addition & 0 deletions examples/demo/examples/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use demo_app::app::App;
use loco_rs::{
boot::{create_app, start, ServeParams, StartMode},
environment::{resolve_from_env, Environment},
tokio,
};
use migration::Migrator;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/examples/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use demo_app::app::App;
use loco_rs::{
boot::{create_context, run_task},
environment::{resolve_from_env, Environment},
task,
task, tokio,
};

#[tokio::main]
Expand Down
1 change: 1 addition & 0 deletions examples/demo/examples/workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use demo_app::app::App;
use loco_rs::{
boot::{create_app, start, ServeParams, StartMode},
environment::{resolve_from_env, Environment},
tokio,
};
use migration::Migrator;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::path::Path;

use async_trait::async_trait;
use loco_rs::{
app::{AppContext, Hooks, Initializer},
async_trait::async_trait,
boot::{create_app, BootResult, StartMode},
cache,
controller::AppRoutes,
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use demo_app::app::App;
use loco_rs::cli;
use loco_rs::{cli, tokio};
use migration::Migrator;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/bin/tool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use demo_app::app::App;
use loco_rs::cli;
use loco_rs::{cli, tokio};
use migration::Migrator;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/controllers/auth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use loco_rs::{controller::bad_request, prelude::*};
use loco_rs::{controller::bad_request, prelude::*, tracing};
use serde::{Deserialize, Serialize};

use crate::{
Expand Down
14 changes: 8 additions & 6 deletions examples/demo/src/controllers/middlewares/handlers/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use std::{
task::{Context, Poll},
};

use axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
};
use futures_util::future::BoxFuture;
use loco_rs::prelude::{auth::JWTWithUser, *};
use loco_rs::{
axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
},
prelude::{auth::JWTWithUser, *},
};
use tower::{Layer, Service};

use crate::models::{roles, sea_orm_active_enums::RolesName, users};
Expand Down
14 changes: 8 additions & 6 deletions examples/demo/src/controllers/middlewares/handlers/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use std::{
task::{Context, Poll},
};

use axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
};
use futures_util::future::BoxFuture;
use loco_rs::prelude::{auth::JWTWithUser, *};
use loco_rs::{
axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
},
prelude::{auth::JWTWithUser, *},
};
use tower::{Layer, Service};

use crate::models::{roles, sea_orm_active_enums::RolesName, users};
Expand Down
14 changes: 8 additions & 6 deletions examples/demo/src/controllers/middlewares/routes/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use std::{
task::{Context, Poll},
};

use axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
};
use futures_util::future::BoxFuture;
use loco_rs::prelude::{auth::JWTWithUser, *};
use loco_rs::{
axum::{
body::Body,
extract::{FromRequestParts, Request},
response::Response,
},
prelude::{auth::JWTWithUser, *},
};
use tower::{Layer, Service};

use crate::models::{roles, users};
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/controllers/notes.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::unnecessary_struct_initialization)]
#![allow(clippy::unused_async)]
use axum::extract::Query;
use loco_rs::{controller::bad_request, model::ModelError, prelude::*};
use loco_rs::{axum::extract::Query, controller::bad_request, model::ModelError, prelude::*};
use sea_orm::Condition;
use serde::{Deserialize, Serialize};

Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/controllers/responses.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(clippy::unused_async)]
use axum_extra::extract::cookie::Cookie;
use loco_rs::prelude::*;
use loco_rs::{axum_extra::extract::cookie::Cookie, prelude::*};
use serde::Serialize;
use utoipa::{openapi, OpenApi, ToSchema};

Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/controllers/upload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::path::PathBuf;

use axum::extract::Multipart;
use loco_rs::prelude::*;
use loco_rs::{axum::extract::Multipart, prelude::*, tracing};

use crate::views;

Expand Down
4 changes: 1 addition & 3 deletions examples/demo/src/initializers/axum_session.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use async_trait::async_trait;
use axum::Router as AxumRouter;
use loco_rs::prelude::*;
use loco_rs::{axum::Router as AxumRouter, prelude::*};

pub struct AxumSessionInitializer;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/initializers/hello_view_engine.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::{async_trait, Extension, Router as AxumRouter};
use loco_rs::{
app::{AppContext, Initializer},
axum::{async_trait, Extension, Router as AxumRouter},
controller::views::{ViewEngine, ViewRenderer},
Result,
};
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/initializers/view_engine.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use axum::{async_trait, Extension, Router as AxumRouter};
use fluent_templates::{ArcLoader, FluentLoader};
use loco_rs::{
app::{AppContext, Initializer},
axum::{async_trait, Extension, Router as AxumRouter},
controller::views::{engines, ViewEngine},
tracing::info,
Error, Result,
};
use tracing::info;

const I18N_DIR: &str = "assets/i18n";
const I18N_SHARED: &str = "assets/i18n/shared.ftl";
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/mailers/auth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// auth mailer
#![allow(non_upper_case_globals)]

use loco_rs::prelude::*;
use loco_rs::{include_dir::include_dir, prelude::*};
use serde_json::json;

use crate::models::users;
Expand Down
10 changes: 5 additions & 5 deletions examples/demo/src/models/users.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use async_trait::async_trait;
use chrono::offset::Local;
use loco_rs::{auth::jwt, hash, prelude::*};
pub use loco_rs::validator;
use loco_rs::{
auth::jwt, chrono::offset::Local, hash, prelude::*, uuid::Uuid, validator::Validate,
};
use serde::{Deserialize, Serialize};
use serde_json::json;
use uuid::Uuid;

pub use super::_entities::users::{self, ActiveModel, Entity, Model};

Expand Down Expand Up @@ -39,7 +39,7 @@ impl Validatable for super::_entities::users::ActiveModel {
}
// </snip>

#[async_trait::async_trait]
#[async_trait]
impl ActiveModelBehavior for super::_entities::users::ActiveModel {
async fn before_save<C>(self, _db: &C, insert: bool) -> Result<Self, DbErr>
where
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/workers/downloader.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::time::Duration;

use loco_rs::prelude::*;
use loco_rs::{prelude::*, tokio::time::sleep};
use serde::{Deserialize, Serialize};
use tokio::time::sleep;

use crate::models::users;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/models/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use demo_app::{
app::App,
models::{roles, sea_orm_active_enums, users, users::RegisterParams, users_roles},
};
use loco_rs::{prelude::*, testing};
use loco_rs::{prelude::*, testing, tokio};
use sea_orm::DatabaseConnection;
use serial_test::serial;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/models/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use demo_app::{
models::users::{self, Model, RegisterParams},
};
use insta::assert_debug_snapshot;
use loco_rs::{model::ModelError, testing};
use loco_rs::{model::ModelError, testing, tokio};
use sea_orm::{ActiveModelTrait, ActiveValue, IntoActiveModel};
use serial_test::serial;

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/tests/models/users_roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use demo_app::{
app::App,
models::{roles, sea_orm_active_enums, users, users::RegisterParams, users_roles},
};
use loco_rs::{prelude::*, testing};
use sea_orm::{ColumnTrait, DatabaseConnection};
use loco_rs::{prelude::*, testing, tokio};
use sea_orm::ColumnTrait;
use serial_test::serial;
macro_rules! configure_insta {
($($expr:expr),*) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::{app::App, models::users};
use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use loco_rs::{testing, tokio};
use rstest::rstest;
use serial_test::serial;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/cache.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::{app::App, models::users};
use insta::assert_debug_snapshot;
use loco_rs::testing;
use loco_rs::{testing, tokio};
use sea_orm::ModelTrait;
use serial_test::serial;

Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/mylayer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use demo_app::{app::App, views::user::UserResponse};
use loco_rs::testing;
use loco_rs::{testing, tokio};
use serial_test::serial;

use crate::requests::prepare_data;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/notes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::{app::App, models::_entities::notes::Entity};
use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use loco_rs::{testing, tokio};
use rstest::rstest;
use sea_orm::entity::prelude::*;
use serde_json;
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/ping.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::app::App;
use insta::assert_debug_snapshot;
use loco_rs::testing;
use loco_rs::{testing, tokio};
use rstest::rstest;

// TODO: see how to dedup / extract this to app-local test utils
Expand Down
7 changes: 5 additions & 2 deletions examples/demo/tests/requests/prepare_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use axum::http::{HeaderName, HeaderValue};
use demo_app::{models::users, views::auth::UserSession};
use loco_rs::{app::AppContext, TestServer};
use loco_rs::{
app::AppContext,
axum::http::{HeaderName, HeaderValue},
TestServer,
};

const USER_EMAIL: &str = "[email protected]";
const USER_PASSWORD: &str = "1234";
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/tests/requests/responses.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use axum::http::HeaderMap;
use demo_app::app::App;
use insta::assert_debug_snapshot;
use loco_rs::testing;
use loco_rs::{axum::http::HeaderMap, testing, tokio};
use rstest::rstest;
use serial_test::serial;
// TODO: see how to dedup / extract this to app-local test utils
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/upload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum_test::multipart::{MultipartForm, Part};
use demo_app::{app::App, views};
use loco_rs::testing;
use loco_rs::{testing, tokio};
use serial_test::serial;

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/tests/requests/user.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use demo_app::app::App;
use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use loco_rs::{testing, tokio};
use serial_test::serial;

use super::prepare_data;
Expand Down
Loading

0 comments on commit 14b3f48

Please sign in to comment.