Initial scaffold: Rust server workspace (sb-api, sb-core, sb-db, sb-auth, sb-shared) + sb-common dependency + systemd

This commit is contained in:
Jan-Peter von Hunnius 2026-08-02 12:48:08 +02:00
commit 7a75a523f0
39 changed files with 183 additions and 0 deletions

19
crates/sb-api/Cargo.toml Normal file
View file

@ -0,0 +1,19 @@
[package]
name = "sb-api"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = { version = "0.8", features = ["ws", "macros"] }
tokio = { version = "1", features = ["full"] }
tower = "0.5"
tower-http = { version = "0.6", features = ["cors", "trace", "compression-gzip"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
sb-core = { path = "../sb-core" }
sb-db = { path = "../sb-db" }
sb-auth = { path = "../sb-auth" }
sb-shared = { path = "../sb-shared" }
sb-common = { path = "/home/jan/Development/skara-brae/skara-brae-common/rust" }

34
crates/sb-api/src/main.rs Normal file
View file

@ -0,0 +1,34 @@
#![allow(dead_code)]
use axum::routing::get;
use axum::Router;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
pub mod routes;
pub mod ws;
#[tokio::main]
async fn main() {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().pretty())
.with(tracing_subscriber::EnvFilter::new(
std::env::var("RUST_LOG").unwrap_or_else(|_| "info".into()),
))
.init();
let app = Router::new()
.route("/health", get(health))
.merge(routes::build());
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080")
.await
.expect("failed to bind");
tracing::info!("listening on {:?}", listener.local_addr());
axum::serve(listener, app).await.expect("server error");
}
async fn health() -> &'static str {
"ok"
}

View file

View file

@ -0,0 +1,2 @@
pub mod auth;
pub mod rate_limit;

View file

@ -0,0 +1,5 @@
use axum::{routing::get, Router};
pub fn build() -> Router {
Router::new().route("/", get(|| async { "skara-brae api" }))
}

View file

View file

View file

@ -0,0 +1,2 @@
pub mod handler;
pub mod channels;