mockforge_collab/
config.rs1use serde::{Deserialize, Serialize};
4use std::time::Duration;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct CollabConfig {
9 pub jwt_secret: String,
11 pub database_url: String,
13 pub bind_address: String,
15 pub max_connections_per_workspace: usize,
17 pub event_bus_capacity: usize,
19 pub auto_commit: bool,
21 pub session_timeout: Duration,
23 pub websocket_ping_interval: Duration,
25 pub max_message_size: usize,
27 pub workspace_dir: Option<String>,
29 pub backup_dir: Option<String>,
31}
32
33impl Default for CollabConfig {
34 fn default() -> Self {
35 Self {
36 jwt_secret: "change-me-in-production".to_string(),
37 database_url: "sqlite://mockforge-collab.db".to_string(),
38 bind_address: "127.0.0.1:8080".to_string(),
39 max_connections_per_workspace: 100,
40 event_bus_capacity: 1000,
41 auto_commit: true,
42 session_timeout: Duration::from_secs(24 * 3600), websocket_ping_interval: Duration::from_secs(30),
44 max_message_size: 1024 * 1024, workspace_dir: Some("./workspaces".to_string()),
46 backup_dir: Some("./backups".to_string()),
47 }
48 }
49}
50
51impl CollabConfig {
52 pub fn from_env() -> Self {
54 Self {
55 jwt_secret: std::env::var("MOCKFORGE_JWT_SECRET")
56 .unwrap_or_else(|_| "change-me-in-production".to_string()),
57 database_url: std::env::var("MOCKFORGE_DATABASE_URL")
58 .unwrap_or_else(|_| "sqlite://mockforge-collab.db".to_string()),
59 bind_address: std::env::var("MOCKFORGE_BIND_ADDRESS")
60 .unwrap_or_else(|_| "127.0.0.1:8080".to_string()),
61 ..Default::default()
62 }
63 }
64}