ninox-server 0.1.0

HTTP/WebSocket server exposing the Ninox engine to the native app and web dashboard.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use ninox_core::{events::Engine, types::Orchestrator};
use axum::{extract::State, http::StatusCode, routing::get, Json, Router};
use std::sync::Arc;

pub fn orchestrators_router(engine: Arc<Engine>) -> Router {
    Router::new()
        .route("/", get(list))
        .with_state(engine)
}

async fn list(State(e): State<Arc<Engine>>) -> Result<Json<Vec<Orchestrator>>, StatusCode> {
    e.store
        .list_orchestrators()
        .map(Json)
        .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
}