Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump version 0.5.0 #593

Merged
merged 3 commits into from
May 29, 2024
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## vNext

## v0.5.0

* refactor auth middleware for supporting bearer, cookie and query. [https://github.com/loco-rs/loco/pull/560](https://github.com/loco-rs/loco/pull/560)
* SeaORM upgraded: `rc1` -> `rc4`. [https://github.com/loco-rs/loco/pull/585](https://github.com/loco-rs/loco/pull/585)
* Adding Cache to app content. [https://github.com/loco-rs/loco/pull/570](https://github.com/loco-rs/loco/pull/570)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"

[package]
name = "loco-rs"
version = "0.4.0"
version = "0.5.0"
description = "The one-person framework for Rust"
homepage = "https://loco.rs/"
documentation = "https://docs.rs/loco-rs"
Expand Down
29 changes: 22 additions & 7 deletions loco-extras/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ tower = { workspace = true, optional = true }
tower-http = { workspace = true, optional = true, features = [
"normalize-path",
] }
opentelemetry = { version = "0.22" , optional = true}
opentelemetry-otlp = { version = "0.15", optional = true, features = ["grpc-tonic"] }
opentelemetry = { version = "0.22", optional = true }
opentelemetry-otlp = { version = "0.15", optional = true, features = [
"grpc-tonic",
] }
axum-tracing-opentelemetry = { version = "0.18", optional = true }
init-tracing-opentelemetry = { version = "0.18", optional = true , features = ["otlp", "tracing_subscriber_ext"] }
init-tracing-opentelemetry = { version = "0.18", optional = true, features = [
"otlp",
"tracing_subscriber_ext",
] }
tracing-opentelemetry-instrumentation-sdk = { version = "0.18", optional = true }
tracing-subscriber = { version = "0.3.18", optional = true , features = ["env-filter", "json"] }
tracing-subscriber = { version = "0.3.18", optional = true, features = [
"env-filter",
"json",
] }
tracing = { version = "0.1.40", optional = true }
mongodb = { version = "2.8.0", optional = true }

[dependencies.loco-rs]
path = "../"
version = "0.4.0"
version = "0.5.0"
default-features = true
features = ["with-db", "auth_jwt"]

Expand All @@ -50,6 +58,13 @@ initializer-prometheus = ["dep:axum-prometheus"]
initializer-extra-db = []
initializer-multi-db = ["dep:serde_json"]
initializer-normalize-path = ["dep:tower", "dep:tower-http"]
initializer-opentelemetry = ["dep:opentelemetry","dep:opentelemetry-otlp","dep:axum-tracing-opentelemetry",
"dep:init-tracing-opentelemetry", "dep:tracing-opentelemetry-instrumentation-sdk","dep:tracing-subscriber","dep:tracing"]
initializer-opentelemetry = [
"dep:opentelemetry",
"dep:opentelemetry-otlp",
"dep:axum-tracing-opentelemetry",
"dep:init-tracing-opentelemetry",
"dep:tracing-opentelemetry-instrumentation-sdk",
"dep:tracing-subscriber",
"dep:tracing",
]
initializer-mongodb = ["dep:mongodb", "dep:serde", "dep:serde_json"]
4 changes: 2 additions & 2 deletions src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ pub async fn create_app<H: Hooks>(
) -> Result<BootResult> {
let app_context = create_context::<H>(environment).await?;

if let Some(pool) = &app_context.redis {
redis::converge(pool, &app_context.config.redis).await?;
if let Some(pool) = &app_context.queue {
redis::converge(pool, &app_context.config.queue).await?;
}

run_app::<H>(&mode, app_context).await
Expand Down
4 changes: 1 addition & 3 deletions starters/lightweight-service/Cargo.lock

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

4 changes: 2 additions & 2 deletions starters/lightweight-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.4.0", default-features = false, features = ["cli"] }
loco-rs = { version = "0.5.0", default-features = false, features = ["cli"] }
serde = "*"
serde_json = "*"
eyre = "*"
Expand All @@ -28,7 +28,7 @@ required-features = []
[dev-dependencies]
serial_test = "*"
rstest = "*"
loco-rs = { version = "0.4.0", default-features = false, features = [
loco-rs = { version = "0.5.0", default-features = false, features = [
"testing",
"cli",
] }
Expand Down
16 changes: 8 additions & 8 deletions starters/rest-api/Cargo.lock

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

4 changes: 2 additions & 2 deletions starters/rest-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.4.0" }
loco-rs = { version = "0.5.0" }
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand Down Expand Up @@ -40,5 +40,5 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { version = "0.4.0", features = ["testing"] }
loco-rs = { version = "0.5.0", features = ["testing"] }
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
4 changes: 2 additions & 2 deletions starters/rest-api/config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ database:
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false

# Redis Configuration
redis:
# Queue Configuration
queue:
# Redis connection URI
uri: {{ get_env(name="REDIS_URL", default="redis://127.0.0.1") }}
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
Expand Down
4 changes: 2 additions & 2 deletions starters/rest-api/config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ database:
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false

# Redis Configuration
redis:
# Queue Configuration
queue:
# Redis connection URI
uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}}
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
Expand Down
2 changes: 1 addition & 1 deletion starters/rest-api/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "src/lib.rs"

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "0.4.0" }
loco-rs = { version = "0.5.0" }

[dependencies.sea-orm-migration]
version = "1.0.0-rc.4"
Expand Down
44 changes: 36 additions & 8 deletions starters/rest-api/src/models/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ impl ActiveModelBehavior for super::_entities::users::ActiveModel {
impl Authenticable for super::_entities::users::Model {
async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::ApiKey.eq(api_key))
.filter(
model::query::condition()
.eq(users::Column::ApiKey, api_key)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand All @@ -77,7 +81,11 @@ impl super::_entities::users::Model {
/// When could not find user by the given token or DB query error
pub async fn find_by_email(db: &DatabaseConnection, email: &str) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::Email.eq(email))
.filter(
model::query::condition()
.eq(users::Column::Email, email)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand All @@ -93,7 +101,11 @@ impl super::_entities::users::Model {
token: &str,
) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::EmailVerificationToken.eq(token))
.filter(
model::query::condition()
.eq(users::Column::EmailVerificationToken, token)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand All @@ -106,7 +118,11 @@ impl super::_entities::users::Model {
/// When could not find user by the given token or DB query error
pub async fn find_by_reset_token(db: &DatabaseConnection, token: &str) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::ResetToken.eq(token))
.filter(
model::query::condition()
.eq(users::Column::ResetToken, token)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand All @@ -120,7 +136,11 @@ impl super::_entities::users::Model {
pub async fn find_by_pid(db: &DatabaseConnection, pid: &str) -> ModelResult<Self> {
let parse_uuid = Uuid::parse_str(pid).map_err(|e| ModelError::Any(e.into()))?;
let user = users::Entity::find()
.filter(users::Column::Pid.eq(parse_uuid))
.filter(
model::query::condition()
.eq(users::Column::Pid, parse_uuid)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand All @@ -133,7 +153,11 @@ impl super::_entities::users::Model {
/// When could not find user by the given token or DB query error
pub async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult<Self> {
let user = users::Entity::find()
.filter(users::Column::ApiKey.eq(api_key))
.filter(
model::query::condition()
.eq(users::Column::ApiKey, api_key)
.build(),
)
.one(db)
.await?;
user.ok_or_else(|| ModelError::EntityNotFound)
Expand Down Expand Up @@ -162,7 +186,11 @@ impl super::_entities::users::Model {
let txn = db.begin().await?;

if users::Entity::find()
.filter(users::Column::Email.eq(&params.email))
.filter(
model::query::condition()
.eq(users::Column::Email, &params.email)
.build(),
)
.one(&txn)
.await?
.is_some()
Expand Down Expand Up @@ -192,7 +220,7 @@ impl super::_entities::users::Model {
///
/// when could not convert user claims to jwt token
pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult<String> {
Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string())?)
Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?)
}
}

Expand Down
16 changes: 8 additions & 8 deletions starters/saas/Cargo.lock

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

4 changes: 2 additions & 2 deletions starters/saas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.4.0" }
loco-rs = { version = "0.5.0" }
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand Down Expand Up @@ -45,5 +45,5 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { version = "0.4.0", features = ["testing"] }
loco-rs = { version = "0.5.0", features = ["testing"] }
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
4 changes: 2 additions & 2 deletions starters/saas/config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ database:
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false

# Redis Configuration
redis:
# Queue Configuration
queue:
# Redis connection URI
uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}}
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
Expand Down
4 changes: 2 additions & 2 deletions starters/saas/config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ database:
# Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode
dangerously_recreate: false

# Redis Configuration
redis:
# Queue Configuration
queue:
# Redis connection URI
uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}}
# Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode
Expand Down
2 changes: 1 addition & 1 deletion starters/saas/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "src/lib.rs"

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "0.4.0" }
loco-rs = { version = "0.5.0" }

[dependencies.sea-orm-migration]
version = "1.0.0-rc.4"
Expand Down
Loading
Loading