summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-11 22:43:14 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-12 00:26:04 -0400
commitf2f820370efbd5c6d0f304f781284a9f68990e21 (patch)
tree7fb25e676dcd8dc694d0cec4df2cc04cab1120ac /src/cli.rs
parent8a4e25c2a7d6235d726499d43fd1721104314e86 (diff)
Wrap the database pool in an App struct.
This is a jumping-off point for adding logic that needs more than just the DB for state, such as chat message handling. The name sucks, but it's the best I've got.
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cli.rs b/src/cli.rs
index eef006e..6b24b65 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -6,7 +6,7 @@ use clap::Parser;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqlitePoolOptions};
use tokio::net;
-use crate::{channel, clock, error::BoxedError, index, login};
+use crate::{app::App, channel, clock, error::BoxedError, index, login};
pub type Result<T> = std::result::Result<T, BoxedError>;
@@ -30,7 +30,7 @@ impl Args {
let app = routers()
.route_layer(middleware::from_fn(clock::middleware))
- .with_state(pool);
+ .with_state(App::from(pool));
let listener = self.listener().await?;
let started_msg = started_msg(&listener)?;
@@ -62,7 +62,7 @@ impl Args {
}
}
-fn routers() -> Router<SqlitePool> {
+fn routers() -> Router<App> {
[channel::router(), login::router()]
.into_iter()
.fold(index::router(), Router::merge)