Skip to content

Commit

Permalink
Release version 0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Dec 3, 2024
1 parent 33be95e commit 8e904d6
Show file tree
Hide file tree
Showing 42 changed files with 238 additions and 159 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"zino-derive",
"zino-dioxus",
"zino-extra",
"zino-http",
"zino-middleware",
"zino-model",
"zino-ntex",
Expand Down
12 changes: 6 additions & 6 deletions examples/actix-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "actix-app"
description = "An example for actix-web integration."
version = "0.9.0"
rust-version = "1.75"
version = "0.9.1"
rust-version = "1.80"
edition = "2021"
publish = false

Expand All @@ -19,7 +19,7 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.26.4"
version = "0.27.0"
features = [
"actix",
"i18n",
Expand All @@ -30,7 +30,7 @@ features = [

[dependencies.zino-core]
path = "../../zino-core"
version = "0.27.4"
version = "0.28.0"
features = [
"cookie",
"env-filter",
Expand All @@ -40,8 +40,8 @@ features = [

[dependencies.zino-derive]
path = "../../zino-derive"
version = "0.24.4"
version = "0.25.0"

[dependencies.zino-model]
path = "../../zino-model"
version = "0.24.4"
version = "0.25.0"
50 changes: 25 additions & 25 deletions examples/actix-app/src/controller/auth.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
use zino::{prelude::*, Request, Response, Result};
use zino_model::user::{JwtAuthService, User};
use zino_model::user::{JwtAuthService, User, UserColumn::*};

pub async fn login(mut req: Request) -> Result {
let current_time = DateTime::now();
let body: Map = req.parse_body().await?;
let (user_id, mut data) = User::generate_token(body).await.extract(&req)?;

let user_updates = json!({
"status": "Active",
"last_login_at": data.remove("current_login_at").and_then(|v| v.as_date_time()),
"last_login_ip": data.remove("current_login_ip"),
"current_login_at": current_time,
"current_login_ip": req.client_ip(),
"$inc": { "login_count": 1 },
});

let mut user_mutations = user_updates.into_map_opt().unwrap_or_default();
let (validation, user) = User::mutate_by_id(&user_id, &mut user_mutations, None)
let last_login_ip = data.remove("current_login_ip");
let last_login_at = data
.remove("current_login_at")
.and_then(|v| v.as_date_time());
let mut mutation = MutationBuilder::<User>::new()
.set(Status, "Active")
.set_if_not_null(LastLoginIp, last_login_ip)
.set_if_some(LastLoginAt, last_login_at)
.set_if_some(CurrentLoginIp, req.client_ip())
.set_now(CurrentLoginAt)
.inc_one(LoginCount)
.set_now(UpdatedAt)
.inc_one(Version)
.build();
let user: User = User::update_by_id(&user_id, &mut mutation)
.await
.extract(&req)?;
if !validation.is_success() {
reject!(req, validation);
}
data.upsert("entry", user.snapshot());

let mut res = Response::default().context(&req);
Expand All @@ -40,20 +40,20 @@ pub async fn refresh(req: Request) -> Result {
pub async fn logout(req: Request) -> Result {
let user_session = req
.get_data::<UserSession<_>>()
.ok_or_else(|| warn!("401 Unauthorized: the user session is invalid"))
.ok_or_else(|| warn!("401 Unauthorized: user session is invalid"))
.extract(&req)?;

let mut mutations = Map::from_entry("status", "SignedOut");
let user_id = user_session.user_id();
let (validation, user) = User::mutate_by_id(user_id, &mut mutations, None)

let mut mutation = MutationBuilder::<User>::new()
.set(Status, "SignedOut")
.set_now(UpdatedAt)
.inc_one(Version)
.build();
let user: User = User::update_by_id(user_id, &mut mutation)
.await
.extract(&req)?;
if !validation.is_success() {
reject!(req, validation);
}

let data = Map::data_entry(user.snapshot());
let mut res = Response::default().context(&req);
res.set_json_data(data);
res.set_json_data(Map::data_entry(user.snapshot()));
Ok(res.into())
}
6 changes: 3 additions & 3 deletions examples/amis-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "amis-app"
description = "An example for amis UI generator."
version = "0.1.0"
version = "0.1.1"
rust-version = "1.80"
edition = "2021"
publish = false
Expand All @@ -12,8 +12,8 @@ features = ["macros"]

[dependencies.zino-amis]
path = "../../zino-amis"
version = "0.1.0"
version = "0.1.1"

[dependencies.zino-core]
path = "../../zino-core"
version = "0.27.4"
version = "0.28.0"
10 changes: 5 additions & 5 deletions examples/axum-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "axum-app"
description = "An example for axum integration."
version = "0.15.0"
version = "0.15.1"
rust-version = "1.80"
edition = "2021"
publish = false
Expand All @@ -19,7 +19,7 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.26.4"
version = "0.27.0"
features = [
"axum",
"i18n",
Expand All @@ -29,7 +29,7 @@ features = [

[dependencies.zino-core]
path = "../../zino-core"
version = "0.27.4"
version = "0.28.0"
features = [
"cookie",
"env-filter",
Expand All @@ -40,8 +40,8 @@ features = [

[dependencies.zino-derive]
path = "../../zino-derive"
version = "0.24.4"
version = "0.25.0"

[dependencies.zino-model]
path = "../../zino-model"
version = "0.24.4"
version = "0.25.0"
8 changes: 4 additions & 4 deletions examples/dioxus-desktop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dioxus-desktop"
description = "An example for Dioxus desktop integration."
version = "0.6.0"
version = "0.6.1"
rust-version = "1.80"
edition = "2021"
publish = false
Expand All @@ -22,14 +22,14 @@ features = [

[dependencies.zino]
path = "../../zino"
version = "0.26.4"
version = "0.27.0"
features = ["dioxus-desktop"]

[dependencies.zino-core]
path = "../../zino-core"
version = "0.27.4"
version = "0.28.0"
features = ["env-filter", "tls-native"]

[dependencies.zino-dioxus]
path = "../../zino-dioxus"
version = "0.9.3"
version = "0.9.4"
4 changes: 2 additions & 2 deletions examples/minimal-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "minimal-app"
description = "A minimal example to run a server."
version = "0.4.0"
version = "0.5.0"
rust-version = "1.80"
edition = "2021"
publish = false

[dependencies.zino]
path = "../../zino"
version = "0.26.4"
version = "0.27.0"
features = ["axum"]

12 changes: 6 additions & 6 deletions examples/ntex-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ntex-app"
description = "An example for ntex integration."
version = "0.3.0"
version = "0.4.0"
rust-version = "1.80"
edition = "2021"
publish = false
Expand All @@ -10,7 +10,7 @@ publish = false
tracing = "0.1.41"

[dependencies.ntex]
version = "2.8.0"
version = "2.9.0"
default-features = false

[dependencies.serde]
Expand All @@ -19,7 +19,7 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.26.4"
version = "0.27.0"
features = [
"i18n",
"jwt",
Expand All @@ -29,7 +29,7 @@ features = [

[dependencies.zino-core]
path = "../../zino-core"
version = "0.27.4"
version = "0.28.0"
features = [
"cookie",
"env-filter",
Expand All @@ -39,8 +39,8 @@ features = [

[dependencies.zino-derive]
path = "../../zino-derive"
version = "0.24.4"
version = "0.25.0"

[dependencies.zino-model]
path = "../../zino-model"
version = "0.24.4"
version = "0.25.0"
50 changes: 25 additions & 25 deletions examples/ntex-app/src/controller/auth.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
use zino::{prelude::*, Request, Response, Result};
use zino_model::user::{JwtAuthService, User};
use zino_model::user::{JwtAuthService, User, UserColumn::*};

pub async fn login(mut req: Request) -> Result {
let current_time = DateTime::now();
let body: Map = req.parse_body().await?;
let (user_id, mut data) = User::generate_token(body).await.extract(&req)?;

let user_updates = json!({
"status": "Active",
"last_login_at": data.remove("current_login_at").and_then(|v| v.as_date_time()),
"last_login_ip": data.remove("current_login_ip"),
"current_login_at": current_time,
"current_login_ip": req.client_ip(),
"$inc": { "login_count": 1 },
});

let mut user_mutations = user_updates.into_map_opt().unwrap_or_default();
let (validation, user) = User::mutate_by_id(&user_id, &mut user_mutations, None)
let last_login_ip = data.remove("current_login_ip");
let last_login_at = data
.remove("current_login_at")
.and_then(|v| v.as_date_time());
let mut mutation = MutationBuilder::<User>::new()
.set(Status, "Active")
.set_if_not_null(LastLoginIp, last_login_ip)
.set_if_some(LastLoginAt, last_login_at)
.set_if_some(CurrentLoginIp, req.client_ip())
.set_now(CurrentLoginAt)
.inc_one(LoginCount)
.set_now(UpdatedAt)
.inc_one(Version)
.build();
let user: User = User::update_by_id(&user_id, &mut mutation)
.await
.extract(&req)?;
if !validation.is_success() {
reject!(req, validation);
}
data.upsert("entry", user.snapshot());

let mut res = Response::default().context(&req);
Expand All @@ -40,20 +40,20 @@ pub async fn refresh(req: Request) -> Result {
pub async fn logout(req: Request) -> Result {
let user_session = req
.get_data::<UserSession<_>>()
.ok_or_else(|| warn!("401 Unauthorized: the user session is invalid"))
.ok_or_else(|| warn!("401 Unauthorized: user session is invalid"))
.extract(&req)?;

let mut mutations = Map::from_entry("status", "SignedOut");
let user_id = user_session.user_id();
let (validation, user) = User::mutate_by_id(user_id, &mut mutations, None)

let mut mutation = MutationBuilder::<User>::new()
.set(Status, "SignedOut")
.set_now(UpdatedAt)
.inc_one(Version)
.build();
let user: User = User::update_by_id(user_id, &mut mutation)
.await
.extract(&req)?;
if !validation.is_success() {
reject!(req, validation);
}

let data = Map::data_entry(user.snapshot());
let mut res = Response::default().context(&req);
res.set_json_data(data);
res.set_json_data(Map::data_entry(user.snapshot()));
Ok(res.into())
}
6 changes: 1 addition & 5 deletions examples/ntex-app/src/model/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ pub struct Tag {
// Info fields.
#[schema(not_null, index_type = "hash", comment = "Tag category")]
category: String,
#[schema(
snapshot,
reference = "Tag",
comment = "Optional parent tag"
)]
#[schema(snapshot, reference = "Tag", comment = "Optional parent tag")]
parent_id: Option<Uuid>,

// Extensions.
Expand Down
4 changes: 2 additions & 2 deletions zino-actix/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zino-actix"
description = "Integrations with actix-web for zino."
version = "0.1.1"
version = "0.1.2"
rust-version = "1.80"
edition = "2021"
license = "MIT"
Expand Down Expand Up @@ -33,7 +33,7 @@ features = ["actix-web"]

[dependencies.zino-core]
path = "../zino-core"
version = "0.27.3"
version = "0.28.0"
features = [
"http02",
"openapi",
Expand Down
4 changes: 2 additions & 2 deletions zino-amis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zino-amis"
description = "UI generator for amis."
version = "0.1.0"
version = "0.1.1"
rust-version = "1.80"
edition = "2021"
license = "MIT"
Expand Down Expand Up @@ -37,5 +37,5 @@ features = ["parse"]

[dependencies.zino-core]
path = "../zino-core"
version = "0.27.3"
version = "0.28.0"
features = ["tracing-subscriber"]
Loading

0 comments on commit 8e904d6

Please sign in to comment.