Initial workspace scaffold

Cargo workspace with 5 crates: buh-entity (pure data structs),
buh-data (Turso/libsql data access), buh-util (scraper, rules,
processor, sync modules), buh-cli (binary "buh" with client/daemon
subcommands), and buh-ws (axum WebSocket server).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-20 09:46:15 +02:00
commit b11a0b7c56
26 changed files with 4131 additions and 0 deletions

16
crates/buh-ws/Cargo.toml Normal file
View File

@@ -0,0 +1,16 @@
[package]
name = "buh-ws"
edition.workspace = true
version.workspace = true
[dependencies]
buh-entity = { workspace = true }
buh-data = { workspace = true }
buh-util = { workspace = true }
axum = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }

34
crates/buh-ws/src/main.rs Normal file
View File

@@ -0,0 +1,34 @@
use axum::{
Router,
extract::ws::{WebSocket, WebSocketUpgrade},
response::IntoResponse,
routing::get,
};
async fn ws_handler(ws: WebSocketUpgrade) -> impl IntoResponse {
ws.on_upgrade(handle_socket)
}
async fn handle_socket(mut socket: WebSocket) {
while let Some(Ok(msg)) = socket.recv().await {
tracing::debug!(?msg, "received");
if socket.send(msg).await.is_err() {
break;
}
}
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
let app = Router::new().route("/ws", get(ws_handler));
let listener = tokio::net::TcpListener::bind("0.0.0.0:9000").await?;
tracing::info!("buh-ws listening on {}", listener.local_addr()?);
axum::serve(listener, app).await?;
Ok(())
}