Skip to content

Commit

Permalink
Cleaning up unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
slyons committed Nov 1, 2023
1 parent e21b541 commit 9a360bc
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 42 deletions.
5 changes: 2 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::errors::RoadieAppError;
use leptos::*;
use leptos_meta::*;
use leptos_router::*;
use crate::auth::frontend::{AuthContext, AuthCard, CLogin, CSignup};
use crate::bag::frontend::ItemList;
use crate::auth::frontend::{AuthContext, AuthCard};
use crate::auth::provide_auth;

#[component]
Expand All @@ -31,7 +30,7 @@ pub fn App() -> impl IntoView {
});

let _is_anonymous = Signal::derive(move || {
match auth_context.user.read() {
match (auth_context.user)() {
Some(Ok(u)) => u.anonymous,
_ => true
}
Expand Down
1 change: 0 additions & 1 deletion src/auth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub async fn signup(
password_confirmation: String
) -> Result<RoadieResult<()>, ServerFnError> {
let pool = db_pool()?;
let auth = auth_session()?;
let response = expect_context::<ResponseOptions>();

if username.trim().len() == 0 {
Expand Down
2 changes: 0 additions & 2 deletions src/auth/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ cfg_if! {

use bcrypt::{hash, DEFAULT_COST};
use sqlx::SqlitePool;
use sqlx::Row;
use sqlx::prelude::*;
use axum_session_auth::{Authentication, HasPermission};
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/bag/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cfg_if! {
if #[cfg(feature="ssr")] {
use crate::auth::auth_session;
use crate::db::db_pool;
use chrono::{DateTime, Utc};
use chrono::Utc;
use http::status::StatusCode;
use leptos_axum::ResponseOptions;
}
Expand Down Expand Up @@ -121,8 +121,6 @@ pub async fn delete_bag_item(item_id: i64) -> Result<RoadieResult<()>, ServerFnE
pub async fn list_bag_items(filter: Option<BagItemFilter>)
-> Result<RoadieResult<BagItemPage>, ServerFnError> {
let pool = db_pool()?;
let auth = auth_session()?;
let response = expect_context::<ResponseOptions>();

let page = BagItem::filter(filter.unwrap_or_default(), &pool).await?;
Ok(Ok(page))
Expand Down
2 changes: 1 addition & 1 deletion src/bag/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn ItemList() -> impl IntoView {
}
);
let page_items = Signal::derive(move || {
page.read()
page()
.map(|op| op.map(|pg| pg.items).unwrap_or(vec![]))
.unwrap_or(vec![])
});
Expand Down
7 changes: 1 addition & 6 deletions src/bag/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,15 @@ cfg_if! {
if #[cfg(feature="ssr")] {
use sqlx::prelude::*;
use sqlx::SqlitePool;
use sqlx::any::AnyQueryResult;
use futures::Future;
use futures::future::try_join_all;

use crate::db::db_pool;
use sea_query_binder::SqlxBinder;
#[cfg(feature="derive")]
use sea_query::*;
use sea_query::{Query, Expr, Iden, IdenStatic,
use sea_query::{Query, Expr, IdenStatic,
Func, SqliteQueryBuilder, SelectStatement, Order, JoinType};
use sea_query::JoinType::Join;
use sea_query::types::{Alias, Asterisk};
use crate::auth::model::UserTable;
use crate::auth::auth_session;
use rand::Rng;
use leptos::logging;

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(dead_code)]

use cfg_if::cfg_if;
pub mod db;
pub mod app;
Expand Down
13 changes: 1 addition & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#![allow(dead_code)]
use cfg_if::cfg_if;

cfg_if! {
if #[cfg(feature="ssr")] {
use axum::{
Router,
};
use roadiebag::app::App;
use roadiebag::service::*;

use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes, handle_server_fns_with_context};
use leptos::{logging::log, provide_context, get_configuration};
use dotenvy::dotenv;
use std::env;

#[tokio::main]
async fn main() {
Expand All @@ -24,10 +14,9 @@ cfg_if! {
let options = load_leptos_options(None, None).await;
let addr = options.site_addr.clone();
let app_state = get_app_state(db_pool, options);
log!("Routes are {:?}", app_state.routes);
let app = get_router(app_state).await;

log!("listening on http://{}", &addr);
tracing::info!("listening on http://{}", &addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
Expand Down
8 changes: 1 addition & 7 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ cfg_if! {

use leptos::*;
use leptos_axum::{generate_route_list, LeptosRoutes, handle_server_fns_with_context};
use leptos::{logging::log, provide_context, get_configuration};
use leptos::{provide_context, get_configuration};

use tower_http::trace::TraceLayer;
use log::Level;
use std::str::FromStr;
use sqlx::{SqlitePool, sqlite::SqlitePoolOptions};
use axum_session::{SessionConfig, SessionLayer, SessionStore};
use axum_session_auth::{AuthSessionLayer, AuthConfig, SessionSqlitePool};
use dotenvy::dotenv;
use std::env;
use std::net::SocketAddr;
use leptos::leptos_config::errors::LeptosConfigError;

#[tracing::instrument(level = "info", fields(error))]
async fn server_fn_handler(State(app_state): State<AppState>, auth_session: AuthSession,
Expand Down Expand Up @@ -112,7 +107,6 @@ cfg_if! {
}

pub fn get_app_state(pool: SqlitePool, options: LeptosOptions) -> AppState {
let addr = options.site_addr;
let routes = generate_route_list(App);
AppState {
leptos_options: options,
Expand Down
9 changes: 4 additions & 5 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use tracing::subscriber::set_global_default;
use tracing::Subscriber;
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_log::LogTracer;
use tracing_subscriber::prelude::*;
//use tracing_subscriber::prelude::*;
use tracing_subscriber::fmt::MakeWriter;
use tracing_subscriber::fmt::{self, format, time};
use tracing_subscriber::fmt::time;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
use tracing_logfmt;
//use tracing_logfmt;

// Compose multiple layers into a `tracing`'s subscriber.
///
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn get_subscriber<Sink>(

Registry::default()
.with(env_filter)
//.with(JsonStorageLayer)
.with(JsonStorageLayer)
.with(formatting_layer)
}

Expand All @@ -84,7 +84,6 @@ pub fn get_subscriber<Sink>(
/// It should only be called once!
pub fn init_subscriber(subscriber: impl Subscriber + Send + Sync) {
let res = LogTracer::init();
println!("Res is {:?}", res);
res.ok();
set_global_default(subscriber).ok();
}
Expand Down

0 comments on commit 9a360bc

Please sign in to comment.