Skip to main content

mockforge_registry_server/
lib.rs

1// Some models and internal modules are not yet wired into routes.
2// Suppress dead_code for the library crate during development.
3#![allow(dead_code)]
4
5//! Pillars: [Cloud]
6//!
7//! MockForge Plugin Registry Server — library crate.
8//!
9//! This crate is being extracted into a reusable library so that both the
10//! multi-tenant SaaS binary (`mockforge-registry-server`) and the single-tenant
11//! OSS admin server (`mockforge-ui`) can share the same domain models,
12//! storage layer, handlers, and authentication middleware.
13//!
14//! Phase 0 of the extraction: expose the existing modules via `lib.rs`
15//! without behavior changes. Later phases will introduce a `RegistryStore`
16//! trait, a SQLite backend, and feature gates for SaaS-only integrations.
17
18/// JWT/password auth helpers moved to `mockforge-registry-core`.
19pub use mockforge_registry_core::auth;
20pub mod ai;
21pub mod cache;
22pub mod circuit_breaker;
23pub mod config;
24pub mod database;
25pub mod deployment;
26pub mod email;
27pub mod error;
28pub mod fly_logs;
29pub mod fly_metrics;
30pub mod handlers;
31pub mod metrics;
32pub mod middleware;
33/// Domain models now live in `mockforge-registry-core`. Re-exported here
34/// so existing `crate::models::X` paths continue to resolve during the
35/// cloud-core extraction.
36pub use mockforge_registry_core::models;
37pub mod pillar_tracking_init;
38pub mod redis;
39pub mod routes;
40pub mod run_queue;
41pub mod storage;
42/// Storage trait + backends now live in `mockforge-registry-core`.
43/// Re-exported so existing `crate::store::*` paths keep working.
44pub use mockforge_registry_core::store;
45/// TOTP/2FA helpers moved to `mockforge-registry-core`.
46pub use mockforge_registry_core::two_factor;
47/// Validation helpers moved to `mockforge-registry-core`.
48pub use mockforge_registry_core::validation;
49pub mod workers;
50
51use std::sync::Arc;
52
53use crate::circuit_breaker::CircuitBreakerRegistry;
54use crate::config::Config;
55use crate::database::Database;
56use crate::redis::RedisPool;
57use crate::storage::PluginStorage;
58use crate::store::RegistryStore;
59
60#[derive(Clone)]
61pub struct AppState {
62    pub db: Database,
63    pub storage: PluginStorage,
64    pub config: Config,
65    pub metrics: Arc<mockforge_observability::prometheus::MetricsRegistry>,
66    pub analytics_db: Option<mockforge_analytics::AnalyticsDatabase>,
67    pub redis: Option<RedisPool>,
68    pub circuit_breakers: CircuitBreakerRegistry,
69    /// Backend-agnostic domain store. Handlers should migrate to this over
70    /// time, in parallel with `db`, so that both Postgres (SaaS) and SQLite
71    /// (OSS admin) backends can satisfy the same handler code.
72    pub store: Arc<dyn RegistryStore>,
73}