From 6d0f3118410b578f3b4a7b4beb7df0d9dc5b4e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 9 Jun 2026 02:23:43 +0200 Subject: [PATCH] routes: reorder routes --- Cargo.lock | 26 ---------- crates/knotty-knot/src/error.rs | 2 +- crates/knotty-knot/src/main.rs | 2 +- crates/knotty-knot/src/router.rs | 2 +- crates/knotty-knot/src/routes/mirror/mod.rs | 12 ----- .../delete.rs => xrpc/knotty/create.rs} | 0 .../mirror/new.rs => xrpc/knotty/list.rs} | 0 crates/knotty-knot/src/xrpc/knotty/mod.rs | 12 +++++ .../knotty-knot/src/{routes => xrpc}/mod.rs | 8 +-- .../xrpc => xrpc/tangled}/create_repo.rs | 0 .../xrpc => xrpc/tangled}/delete_repo.rs | 0 .../src/{routes/xrpc => xrpc/tangled}/mod.rs | 0 .../{routes/xrpc => xrpc/tangled}/owner.rs | 0 crates/knotty/Cargo.toml | 16 ------ crates/knotty/src/main.rs | 50 ------------------- 15 files changed, 19 insertions(+), 111 deletions(-) delete mode 100644 crates/knotty-knot/src/routes/mirror/mod.rs rename crates/knotty-knot/src/{routes/mirror/delete.rs => xrpc/knotty/create.rs} (100%) rename crates/knotty-knot/src/{routes/mirror/new.rs => xrpc/knotty/list.rs} (100%) create mode 100644 crates/knotty-knot/src/xrpc/knotty/mod.rs rename crates/knotty-knot/src/{routes => xrpc}/mod.rs (53%) rename crates/knotty-knot/src/{routes/xrpc => xrpc/tangled}/create_repo.rs (100%) rename crates/knotty-knot/src/{routes/xrpc => xrpc/tangled}/delete_repo.rs (100%) rename crates/knotty-knot/src/{routes/xrpc => xrpc/tangled}/mod.rs (100%) rename crates/knotty-knot/src/{routes/xrpc => xrpc/tangled}/owner.rs (100%) delete mode 100644 crates/knotty/Cargo.toml delete mode 100644 crates/knotty/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 5a2989a..b32d9cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2111,21 +2111,6 @@ dependencies = [ "signature", ] -[[package]] -name = "knotty" -version = "0.0.0" -dependencies = [ - "clap", - "http", - "jacquard", - "miette", - "serde_json", - "tokio", - "tracing", - "tracing-subscriber", - "uuid", -] - [[package]] name = "knotty-knot" version = "0.0.0" @@ -4233,17 +4218,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d258b83ceec21034727ecee8c382cfa6c3e133699b0742c64571814fb420c9f7" -dependencies = [ - "getrandom 0.4.2", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "valuable" version = "0.1.1" diff --git a/crates/knotty-knot/src/error.rs b/crates/knotty-knot/src/error.rs index 14793d2..52ab192 100644 --- a/crates/knotty-knot/src/error.rs +++ b/crates/knotty-knot/src/error.rs @@ -1,4 +1,4 @@ -use axum::{http::StatusCode, response::IntoResponse, Json}; +use axum::{Json, http::StatusCode, response::IntoResponse}; use serde::Serialize; #[derive(Serialize)] diff --git a/crates/knotty-knot/src/main.rs b/crates/knotty-knot/src/main.rs index df109b9..257161f 100644 --- a/crates/knotty-knot/src/main.rs +++ b/crates/knotty-knot/src/main.rs @@ -1,8 +1,8 @@ mod error; mod keypair; mod router; -mod routes; mod state; +mod xrpc; use std::path::PathBuf; diff --git a/crates/knotty-knot/src/router.rs b/crates/knotty-knot/src/router.rs index c3de605..85500e3 100644 --- a/crates/knotty-knot/src/router.rs +++ b/crates/knotty-knot/src/router.rs @@ -6,7 +6,7 @@ use crate::state::KnotState; pub fn router(state: KnotState) -> Router { let did_doc = state.did_doc.clone(); - crate::routes::router() + crate::xrpc::router() .with_state(state) .merge(knotty_web::router()) .merge(did_web::did_web_router(did_doc)) diff --git a/crates/knotty-knot/src/routes/mirror/mod.rs b/crates/knotty-knot/src/routes/mirror/mod.rs deleted file mode 100644 index 88b9603..0000000 --- a/crates/knotty-knot/src/routes/mirror/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -use axum::{Router, routing::post}; - -use crate::state::KnotState; - -mod delete; -mod new; - -pub fn router() -> Router { - Router::new() - .route("/", post(new::handler)) - .route("/delete", post(delete::handler)) -} diff --git a/crates/knotty-knot/src/routes/mirror/delete.rs b/crates/knotty-knot/src/xrpc/knotty/create.rs similarity index 100% rename from crates/knotty-knot/src/routes/mirror/delete.rs rename to crates/knotty-knot/src/xrpc/knotty/create.rs diff --git a/crates/knotty-knot/src/routes/mirror/new.rs b/crates/knotty-knot/src/xrpc/knotty/list.rs similarity index 100% rename from crates/knotty-knot/src/routes/mirror/new.rs rename to crates/knotty-knot/src/xrpc/knotty/list.rs diff --git a/crates/knotty-knot/src/xrpc/knotty/mod.rs b/crates/knotty-knot/src/xrpc/knotty/mod.rs new file mode 100644 index 0000000..1a9824e --- /dev/null +++ b/crates/knotty-knot/src/xrpc/knotty/mod.rs @@ -0,0 +1,12 @@ +use axum::{Router, routing::post}; + +use crate::state::KnotState; + +mod create; +mod list; + +pub fn router() -> Router { + Router::new() + .route("/xrpc/dev.drawbu.knotty.create", post(create::handler)) + .route("/xrpc/dev.drawbu.knotty.list", post(list::handler)) +} diff --git a/crates/knotty-knot/src/routes/mod.rs b/crates/knotty-knot/src/xrpc/mod.rs similarity index 53% rename from crates/knotty-knot/src/routes/mod.rs rename to crates/knotty-knot/src/xrpc/mod.rs index 3ad8545..e3b8088 100644 --- a/crates/knotty-knot/src/routes/mod.rs +++ b/crates/knotty-knot/src/xrpc/mod.rs @@ -2,11 +2,11 @@ use axum::Router; use crate::state::KnotState; -mod mirror; -mod xrpc; +mod knotty; +mod tangled; pub fn router() -> Router { Router::new() - .merge(xrpc::router()) - .nest("/mirror", mirror::router()) + .merge(tangled::router()) + .merge(knotty::router()) } diff --git a/crates/knotty-knot/src/routes/xrpc/create_repo.rs b/crates/knotty-knot/src/xrpc/tangled/create_repo.rs similarity index 100% rename from crates/knotty-knot/src/routes/xrpc/create_repo.rs rename to crates/knotty-knot/src/xrpc/tangled/create_repo.rs diff --git a/crates/knotty-knot/src/routes/xrpc/delete_repo.rs b/crates/knotty-knot/src/xrpc/tangled/delete_repo.rs similarity index 100% rename from crates/knotty-knot/src/routes/xrpc/delete_repo.rs rename to crates/knotty-knot/src/xrpc/tangled/delete_repo.rs diff --git a/crates/knotty-knot/src/routes/xrpc/mod.rs b/crates/knotty-knot/src/xrpc/tangled/mod.rs similarity index 100% rename from crates/knotty-knot/src/routes/xrpc/mod.rs rename to crates/knotty-knot/src/xrpc/tangled/mod.rs diff --git a/crates/knotty-knot/src/routes/xrpc/owner.rs b/crates/knotty-knot/src/xrpc/tangled/owner.rs similarity index 100% rename from crates/knotty-knot/src/routes/xrpc/owner.rs rename to crates/knotty-knot/src/xrpc/tangled/owner.rs diff --git a/crates/knotty/Cargo.toml b/crates/knotty/Cargo.toml deleted file mode 100644 index 9f2837c..0000000 --- a/crates/knotty/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "knotty" -edition = "2024" -version.workspace = true -description.workspace = true - -[dependencies] -clap.workspace = true -http.workspace = true -jacquard.workspace = true -miette.workspace = true -serde_json.workspace = true -tokio.workspace = true -tracing.workspace = true -tracing-subscriber.workspace = true -uuid.workspace = true diff --git a/crates/knotty/src/main.rs b/crates/knotty/src/main.rs deleted file mode 100644 index 6486593..0000000 --- a/crates/knotty/src/main.rs +++ /dev/null @@ -1,50 +0,0 @@ -use clap::Parser; -use jacquard::CowStr; -use jacquard::api::sh_tangled; -use jacquard::client::{Agent, AgentSessionExt, FileAuthStore}; -use jacquard::oauth::client::OAuthClient; -use jacquard::oauth::loopback::LoopbackConfig; -use jacquard::types::string::Datetime; - -#[derive(Parser, Debug)] -#[command(author, version, about = "Jacquard - OAuth (DPoP) loopback demo")] -struct Args { - /// Handle (e.g., alice.bsky.social), DID, or PDS URL - input: CowStr<'static>, - - /// Path to auth store file (will be created if missing) - #[arg(long, default_value = "/tmp/knotty-oauth-session.json")] - store: String, -} - -#[tokio::main] -async fn main() -> miette::Result<()> { - tracing_subscriber::fmt::init(); - let args = Args::parse(); - - let oauth = OAuthClient::with_default_config(FileAuthStore::new(&args.store)); - let session = oauth - .login_with_local_server(args.input, Default::default(), LoopbackConfig::default()) - .await?; - - let agent: Agent<_> = Agent::from(session); - - let id = uuid::Uuid::now_v7(); - let repo = sh_tangled::repo::Repo { - name: CowStr::from(format!("knotty-test-{id}")), - description: None, - knot: CowStr::from("knot1.tangled.sh"), - created_at: Datetime::now(), - source: None, - spindle: None, - labels: None, - topics: None, - website: None, // todo: fill with mirror origin - extra_data: None, - }; - - let output = agent.create_record(repo, None).await?; - tracing::info!("created repo: {}", output.uri); - - Ok(()) -} -- 2.51.2