Skip to content

Commit

Permalink
Fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Aug 12, 2024
1 parent d1ad4a8 commit eb671d8
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 75 deletions.
3 changes: 2 additions & 1 deletion examples/loco_example/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ use todolist::app::App;

#[tokio::main]
async fn main() -> eyre::Result<()> {
cli::main::<App, Migrator>().await
cli::main::<App, Migrator>().await?;
Ok(())
}
7 changes: 4 additions & 3 deletions examples/loco_example/tests/tasks/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! ```sh
//! cargo run task seed_data refresh:true
//! ```
use std::collections::BTreeMap;

use loco_rs::{db, prelude::*};
use migration::Migrator;
Expand All @@ -29,8 +28,10 @@ impl Task for SeedData {
detail: "Task for seeding data".to_string(),
}
}
async fn run(&self, app_context: &AppContext, vars: &BTreeMap<String, String>) -> Result<()> {
let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true");
async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> {
let refresh = vars
.cli_arg("refresh")
.is_ok_and(|refresh| refresh == "true");

if refresh {
db::reset::<Migrator>(&app_context.db).await?;
Expand Down
3 changes: 2 additions & 1 deletion examples/loco_seaography/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ use migration::Migrator;

#[tokio::main]
async fn main() -> eyre::Result<()> {
cli::main::<App, Migrator>().await
cli::main::<App, Migrator>().await?;
Ok(())
}
2 changes: 1 addition & 1 deletion examples/loco_seaography/src/models/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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
7 changes: 4 additions & 3 deletions examples/loco_seaography/src/tasks/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! ```sh
//! cargo run task seed_data refresh:true
//! ```
use std::collections::BTreeMap;

use loco_rs::{db, prelude::*};
use migration::Migrator;
Expand All @@ -31,8 +30,10 @@ impl Task for SeedData {
}
}

async fn run(&self, app_context: &AppContext, vars: &BTreeMap<String, String>) -> Result<()> {
let refresh = vars.get("refresh").is_some_and(|refresh| refresh == "true");
async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> {
let refresh = vars
.cli_arg("refresh")
.is_ok_and(|refresh| refresh == "true");

if refresh {
db::reset::<Migrator>(&app_context.db).await?;
Expand Down
Loading

0 comments on commit eb671d8

Please sign in to comment.