1use std::sync::Arc;
4use ggen_core::telemetry::TelemetryConfig;
5
6#[derive(Clone)]
8pub struct AppState {
9 pub config: Arc<ApiConfig>,
11 pub telemetry: Arc<TelemetryConfig>,
13}
14
15#[derive(Debug, Clone)]
17pub struct ApiConfig {
18 pub host: String,
19 pub port: u16,
20 pub jwt_secret: String,
21 pub stripe_key: Option<String>,
22 pub max_requests_per_minute: u32,
23 pub max_api_calls_per_minute: u32,
24 pub base_url: String,
25}
26
27impl Default for ApiConfig {
28 fn default() -> Self {
29 Self {
30 host: "127.0.0.1".to_string(),
31 port: 3000,
32 jwt_secret: "change-me-in-production".to_string(),
33 stripe_key: None,
34 max_requests_per_minute: 100,
35 max_api_calls_per_minute: 1000,
36 base_url: "http://localhost:3000".to_string(),
37 }
38 }
39}
40
41impl AppState {
42 pub fn new(
43 config: ApiConfig,
44 telemetry: TelemetryConfig,
45 ) -> Self {
46 Self {
47 config: Arc::new(config),
48 telemetry: Arc::new(telemetry),
49 }
50 }
51}