add config-sqlite and http-api adapters
SQLite config store: full ConfigRepository impl with JSON serialization for mappings, layouts, data source configs. 12 integration tests. HTTP API: Axum REST endpoints for widgets, data sources, layout, presets. 6 integration tests using tower::oneshot. Port traits updated to return Send futures for Axum compatibility.
This commit is contained in:
34
crates/adapters/http-api/src/lib.rs
Normal file
34
crates/adapters/http-api/src/lib.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
mod dto;
|
||||
mod routes;
|
||||
|
||||
use std::sync::Arc;
|
||||
use axum::Router;
|
||||
use tower_http::cors::CorsLayer;
|
||||
use domain::{ConfigRepository, EventPublisher};
|
||||
|
||||
pub struct AppState<C, E> {
|
||||
pub config: Arc<C>,
|
||||
pub events: Arc<E>,
|
||||
}
|
||||
|
||||
impl<C, E> Clone for AppState<C, E> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
config: self.config.clone(),
|
||||
events: self.events.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn router<C, E>(state: AppState<C, E>) -> Router
|
||||
where
|
||||
C: ConfigRepository + Send + Sync + 'static,
|
||||
C::Error: std::fmt::Debug + Send,
|
||||
E: EventPublisher + Send + Sync + 'static,
|
||||
E::Error: std::fmt::Debug + Send,
|
||||
{
|
||||
Router::new()
|
||||
.nest("/api", routes::api_routes())
|
||||
.layer(CorsLayer::permissive())
|
||||
.with_state(state)
|
||||
}
|
||||
Reference in New Issue
Block a user