perfgate_server/lib.rs
1//! perfgate-server - REST API server for centralized baseline management.
2//!
3//! This crate provides a REST API server for storing and managing performance
4//! baselines. It supports multiple storage backends (in-memory, SQLite, PostgreSQL)
5//! and includes authentication via API keys.
6//!
7//! # Features
8//!
9//! - **Multi-tenancy**: Projects/namespaces for isolation
10//! - **Version history**: Track baseline versions over time
11//! - **Rich metadata**: Git refs, tags, custom metadata
12//! - **Access control**: Role-based permissions (Viewer, Contributor, Promoter, Admin)
13//! - **Multiple backends**: In-memory, SQLite, PostgreSQL (planned)
14//!
15//! # Quick Start
16//!
17//! ```rust,no_run
18//! use perfgate_server::{ServerConfig, StorageBackend, run_server};
19//!
20//! #[tokio::main]
21//! async fn main() {
22//! let config = ServerConfig::new()
23//! .bind("0.0.0.0:8080").unwrap()
24//! .storage_backend(StorageBackend::Sqlite)
25//! .sqlite_path("perfgate.db");
26//!
27//! run_server(config).await.unwrap();
28//! }
29//! ```
30//!
31//! # API Endpoints
32//!
33//! | Method | Path | Description |
34//! |--------|------|-------------|
35//! | POST | `/projects/{project}/baselines` | Upload a baseline |
36//! | GET | `/projects/{project}/baselines/{benchmark}/latest` | Get latest baseline |
37//! | GET | `/projects/{project}/baselines/{benchmark}/versions/{version}` | Get specific version |
38//! | GET | `/projects/{project}/baselines` | List baselines |
39//! | DELETE | `/projects/{project}/baselines/{benchmark}/versions/{version}` | Delete baseline |
40//! | POST | `/projects/{project}/baselines/{benchmark}/promote` | Promote version |
41//! | GET | `/health` | Health check |
42
43pub mod auth;
44pub mod error;
45pub mod handlers;
46pub mod models;
47pub mod oidc;
48pub mod server;
49pub mod storage;
50
51#[cfg(any(test, feature = "test-utils"))]
52pub mod testing;
53
54pub use auth::{ApiKey, ApiKeyStore, AuthContext, AuthState, JwtClaims, JwtConfig, Role, Scope};
55pub use error::{AuthError, ConfigError, StoreError};
56pub use models::*;
57pub use oidc::{OidcConfig, OidcProvider};
58pub use server::{ServerConfig, StorageBackend, run_server};
59pub use storage::{BaselineStore, InMemoryStore, SqliteStore, StorageHealth};
60
61/// Server version string.
62pub const VERSION: &str = env!("CARGO_PKG_VERSION");
63
64#[cfg(test)]
65mod tests {
66 use super::*;
67
68 #[test]
69 fn test_version() {
70 assert!(!VERSION.is_empty());
71 }
72}