mabel/src/state.rs

25 lines
584 B
Rust
Raw Normal View History

2023-06-30 13:02:20 +00:00
use serde::{Deserialize, Serialize};
2023-06-29 12:08:59 +00:00
use sqlx::{Pool, Postgres};
2023-06-30 13:02:20 +00:00
#[derive(Deserialize, Serialize, Clone)]
pub struct Config {
pub bind: String,
pub database_url: String,
pub session_duration: i32, // in seconds
}
impl Default for Config {
fn default() -> Self {
Config {
bind: "127.0.0.1:3000".to_owned(),
database_url: "postgres://artificiale:changeme@localhost/artificiale".to_owned(),
session_duration: 1440, // 24min
}
}
}
2023-06-29 12:08:59 +00:00
pub struct AppState {
pub database: Pool<Postgres>,
2023-06-30 13:02:20 +00:00
pub config: Config,
2023-06-29 12:08:59 +00:00
}