Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

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

173 changes: 125 additions & 48 deletions create-rust-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ readme = "../README.md"
repository = "https://github.com/Wulf/create-rust-app"
license = "MIT OR Apache-2.0"
keywords = ["react", "typescript", "generation", "backend", "frontend"]
categories = ["command-line-utilities", "development-tools", "web-programming", "config", "database"]
categories = [
"command-line-utilities",
"development-tools",
"web-programming",
"config",
"database",
]

[dependencies]
##
Expand All @@ -17,10 +23,14 @@ categories = ["command-line-utilities", "development-tools", "web-programming",
dotenv = "0.15.0" # + plugin_dev
serde_json = "1.0.93"
lettre = "0.10.2"
tera = { version="1.17.0" }
lazy_static = { version="1.4.0" }
tera = { version = "1.17.0" }
lazy_static = { version = "1.4.0" }
serde = { version = "1.0.152", features = ["derive"] }
diesel = { version="2.0.0-rc.1", default-features = false, features = ["uuid", "r2d2", "chrono"] } # + plugin_dev, plugin_auth
diesel = { version = "2.0.0-rc.1", default-features = false, features = [
"uuid",
"r2d2",
"chrono",
] } # + plugin_dev, plugin_auth
once_cell = "1.17.1"

##
Expand All @@ -35,83 +45,150 @@ libsqlite3-sys = { version = "0.25", optional = true, features = ["bundled"] }
##

# plugin_auth
rust-argon2 = { optional=true, version="1.0" }
rand = { optional=true, version="0.8.5" }
jsonwebtoken = { optional=true, version="8.2.0" }
tsync = { optional=true, version="1.6.0" }
chrono = { optional=true, version = "0.4.23", default-features = false, features = ["clock", "serde"] }
rust-argon2 = { optional = true, version = "1.0" }
rand = { optional = true, version = "0.8.5" }
jsonwebtoken = { optional = true, version = "8.2.0" }
tsync = { optional = true, version = "1.6.0" }
chrono = { optional = true, version = "0.4.23", default-features = false, features = [
"clock",
"serde",
] }
dyn-clone = { optional = true, version = "1.0" } # needed to allow the Mailer struct to be cloned

# plugin_dev
diesel_migrations = { optional=true, version="2.0.0" }
cargo_metadata = { optional=true, version="0.15.2" }
watchexec = { optional=true, version="2.2.0" }
diesel_migrations = { optional = true, version = "2.0.0" }
cargo_metadata = { optional = true, version = "0.15.2" }
watchexec = { optional = true, version = "2.2.0" }
#### tracing = { optional=true, version="0.1" }
#### tracing-subscriber = { optional=true, version="0.3.16", features=["env-filter"] }
reqwest = { optional=true, version="0.11.13" }
clearscreen = { optional=true, version="2.0.0" }
open = { optional=true, version="3.2.0" }
cargo_toml = { optional=true, version = "0.14.0" }
reqwest = { optional = true, version = "0.11.13" }
clearscreen = { optional = true, version = "2.0.0" }
open = { optional = true, version = "3.2.0" }
cargo_toml = { optional = true, version = "0.14.0" }

# plugin_storage
aws-config = { optional=true, version="0.14.0" }
aws-types = { optional=true, version="0.8.0" }
aws-endpoint = { optional=true, version="0.14.0" }
aws-sdk-s3 = { optional=true, version="0.8.0" }
http = { optional=true, version="0.2.6" }
diesel_derives = { optional=true, version="2.0.1" }
uuid = { optional=true, version="1.2.2", features=["v4", "serde"] }
md5 = { optional=true, version="0.7.0" }
base64 = { optional=true, version="0.21.0" }
aws-config = { optional = true, version = "0.14.0" }
aws-types = { optional = true, version = "0.8.0" }
aws-endpoint = { optional = true, version = "0.14.0" }
aws-sdk-s3 = { optional = true, version = "0.8.0" }
http = { optional = true, version = "0.2.6" }
diesel_derives = { optional = true, version = "2.0.1" }
uuid = { optional = true, version = "1.2.2", features = ["v4", "serde"] }
md5 = { optional = true, version = "0.7.0" }
base64 = { optional = true, version = "0.21.0" }

# plugin_utoipa dependencies
utoipa = { optional=true, version="3", features=["actix_extras", "chrono", "openapi_extensions"] }
utoipa-swagger-ui = { optional=true, version="3", features=["actix-web"]}
utoipa = { optional = true, version = "3", features = [
"actix_extras",
"chrono",
"openapi_extensions",
] }
utoipa-swagger-ui = { optional = true, version = "3", features = ["actix-web"] }

# plugin_tasks
fang = { optional=true, version = "0.10.3" }
fang = { optional = true, version = "0.10.3" }

##
## BACKENDS
##

# poem dependencies
poem = { optional=true, version="1.3.52", features=["anyhow", "cookie", "static-files"] }
poem = { optional = true, version = "1.3.52", features = [
"anyhow",
"cookie",
"static-files",
] }

# actix_web dependencies
actix-multipart = { optional=true, version="0.4.0" }
actix-files = { optional=true, version="0.6.2" }
actix-http = { optional=true, version="3.0.4" }
actix-web = { optional=true, version="4.2.1" }
actix-web-httpauth = { optional=true, version="0.8.0" }
derive_more = { optional=true, version="0.99.17" }
futures = { optional=true, version="0.3.25" }
env_logger = { optional=true, version= "0.10.0" }
actix-multipart = { optional = true, version = "0.4.0" }
actix-files = { optional = true, version = "0.6.2" }
actix-http = { optional = true, version = "3.0.4" }
actix-web = { optional = true, version = "4.2.1" }
actix-web-httpauth = { optional = true, version = "0.8.0" }
derive_more = { optional = true, version = "0.99.17" }
futures = { optional = true, version = "0.3.25" }
env_logger = { optional = true, version = "0.10.0" }

# axum dependencies (not yet released; only used for plugin_dev)

axum = { optional=true, version="0.6.1" }
axum = { optional = true, version = "0.6.1" }

##
## MISC - here, we list deps which are required by multiple features but are not required in all configurations
##

mime_guess = { optional=true, version="2.0.4" } # backend_poem, plugin_storage
anyhow = { optional=true, version="1.0.57" } # backend_poem, plugin_auth, plugin_dev
tokio = { optional=true, version = "1", features = ["full"] } # backend_poem, backend_axum, plugin_storage
mime_guess = { optional = true, version = "2.0.4" } # backend_poem, plugin_storage
anyhow = { optional = true, version = "1.0.57" } # backend_poem, plugin_auth, plugin_dev
tokio = { optional = true, version = "1", features = [
"full",
] } # backend_poem, backend_axum, plugin_storage
async-priority-channel = "0.1.0"
futures-util = { optional=true, version = "0.3.25" } # plugin_dev, TODO:plugin_storage?
futures-util = { optional = true, version = "0.3.25" } # plugin_dev, TODO:plugin_storage?

[features]
default = ["backend_actix-web", "database_postgres", "plugin_auth", "plugin_container", "plugin_dev", "plugin_graphql", "plugin_storage", "plugin_utoipa"]
plugin_dev = ["backend_axum", "cargo_toml", "open", "reqwest", "anyhow", "clearscreen", "watchexec", "cargo_metadata", "diesel_migrations", "futures-util"]
default = [
"backend_actix-web",
"database_postgres",
"plugin_auth",
"plugin_container",
"plugin_dev",
"plugin_graphql",
"plugin_storage",
"plugin_utoipa",
]
plugin_dev = [
"backend_axum",
"cargo_toml",
"open",
"reqwest",
"anyhow",
"clearscreen",
"watchexec",
"cargo_metadata",
"diesel_migrations",
"futures-util",
]
plugin_container = []
plugin_auth = ["anyhow", "rust-argon2", "rand", "jsonwebtoken", "chrono", "tsync"]
plugin_storage = [ "aws-config", "aws-types", "aws-endpoint", "aws-sdk-s3", "tokio", "http", "diesel_derives", "uuid", "md5", "mime_guess", "base64" ] # note: might need to add "futures-util"?
plugin_auth = [
"anyhow",
"rust-argon2",
"rand",
"jsonwebtoken",
"chrono",
"tsync",
"dyn-clone",
]
plugin_storage = [
"aws-config",
"aws-types",
"aws-endpoint",
"aws-sdk-s3",
"tokio",
"http",
"diesel_derives",
"uuid",
"md5",
"mime_guess",
"base64",
] # note: might need to add "futures-util"?
plugin_graphql = []
plugin_utoipa = ["utoipa", "utoipa-swagger-ui", "backend_actix-web"]
plugin_tasks = ["fang"]
backend_poem = ["poem", "anyhow", "mime_guess", "tokio"]
backend_actix-web = ["actix-web", "actix-http", "actix-files", "actix-multipart", "actix-web-httpauth","derive_more", "futures", "env_logger"]
backend_actix-web = [
"actix-web",
"actix-http",
"actix-files",
"actix-multipart",
"actix-web-httpauth",
"derive_more",
"futures",
"env_logger",
]
backend_axum = ["axum", "axum/ws", "tokio"]
database_sqlite = ["diesel/sqlite", "diesel/returning_clauses_for_sqlite_3_35", "libsqlite3-sys/bundled"]
database_sqlite = [
"diesel/sqlite",
"diesel/returning_clauses_for_sqlite_3_35",
"libsqlite3-sys/bundled",
]
database_postgres = ["diesel/postgres"]
26 changes: 14 additions & 12 deletions create-rust-app/src/auth/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,9 @@ pub fn register(
)
.unwrap();

mail::auth_register::send(
mailer,
&user.email,
&format!("http://localhost:3000/activate?token={token}"),
);
mailer
.templates
.send_register(mailer, &user.email, &format!("activate?token={token}"));

Ok(())
}
Expand Down Expand Up @@ -598,7 +596,7 @@ pub fn activate(
return Err((500, "Could not activate user."));
}

mail::auth_activated::send(mailer, &user.email);
mailer.templates.send_activated(mailer, &user.email);

Ok(())
}
Expand Down Expand Up @@ -642,11 +640,15 @@ pub fn forgot_password(
)
.unwrap();

let link = &format!("http://localhost:3000/reset?token={reset_token}");
mail::auth_recover_existent_account::send(mailer, &user.email, link);
let link = &format!("reset?token={reset_token}");
mailer
.templates
.send_recover_existent_account(mailer, &user.email, link);
} else {
let link = &"http://localhost:300/register".to_string();
mail::auth_recover_nonexistent_account::send(mailer, &item.email, link);
let link = &"register".to_string();
mailer
.templates
.send_recover_nonexistent_account(mailer, &item.email, link);
}

Ok(())
Expand Down Expand Up @@ -718,7 +720,7 @@ pub fn change_password(
return Err((500, "Could not update password"));
}

mail::auth_password_changed::send(mailer, &user.email);
mailer.templates.send_password_changed(mailer, &user.email);

Ok(())
}
Expand Down Expand Up @@ -794,7 +796,7 @@ pub fn reset_password(
return Err((500, "Could not update password"));
}

mail::auth_password_reset::send(mailer, &user.email);
mailer.templates.send_password_reset(mailer, &user.email);

Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions create-rust-app/src/auth/mail/auth_activated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Mailer;

#[allow(dead_code)]
pub fn send(mailer: &Mailer, to_email: &str) {
let subject = "Account activated)";
let subject = "Account activated";
let text = r#"
(This is an automated message.)

Expand All @@ -12,11 +12,11 @@ Your account has been activated!
"#
.to_string();
let html = r#"
(This is an automated message.)
<p>(This is an automated message.)</p>

Hello,
<p>Hello,</p>

Your account has been activated!
<p>Your account has been activated!</p>
"#
.to_string();

Expand Down
8 changes: 4 additions & 4 deletions create-rust-app/src/auth/mail/auth_password_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Mailer;

#[allow(dead_code)]
pub fn send(mailer: &Mailer, to_email: &str) {
let subject = "Your password was changed)";
let subject = "Your password was changed";
let text = r#"
(This is an automated message.)

Expand All @@ -12,11 +12,11 @@ Your password was changed successfully!
"#
.to_string();
let html = r#"
(This is an automated message.)
<p>(This is an automated message.)</p>

Hello,
<p>Hello,</p>

Your password was changed successfully!
<p>Your password was changed successfully!</p>
"#
.to_string();

Expand Down
8 changes: 4 additions & 4 deletions create-rust-app/src/auth/mail/auth_password_reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::Mailer;

#[allow(dead_code)]
pub fn send(mailer: &Mailer, to_email: &str) {
let subject = "Your password was reset)";
let subject = "Your password was reset";
let text = r#"
(This is an automated message.)

Expand All @@ -13,11 +13,11 @@ Your password was successfully reset!
.to_string();

let html = r#"
(This is an automated message.)
<p>(This is an automated message.)</p>

Hello,
<p>Hello,</p>

Your password was successfully reset!
<p>Your password was successfully reset!</p>
"#
.to_string();

Expand Down
Loading