diff --git a/Cargo.lock b/Cargo.lock index 4f60d66..7cc22a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,8 +51,11 @@ dependencies = [ name = "api" version = "0.1.0" dependencies = [ + "atproto", "axum", "http", + "serde", + "serde_json", "tokio", "tracing", "tracing-subscriber", @@ -84,6 +87,10 @@ version = "0.1.0" dependencies = [ "atrium-api", "lazy-regex", + "serde", + "serde_json", + "tracing", + "tracing-subscriber", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d1d65a1..908c860 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,11 @@ [workspace] resolver = "3" members = [ "api", "atproto","db", "ingestor"] + +[workspace.dependencies] +atproto = { path = "./atproto" } +serde = "1.0.219" +serde_json = "1.0.140" +tokio = { version = "1.45.0", features = ["macros", "rt-multi-thread"] } +tracing = "0.1.41" +tracing-subscriber = "0.3.19" diff --git a/api/Cargo.toml b/api/Cargo.toml new file mode 100644 index 0000000..1fc049c --- /dev/null +++ b/api/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "api" +version = "0.1.0" +edition = "2024" + +[dependencies] +atproto.workspace = true +axum = { version = "0.8.3", features = ["json"] } +http = "1.3.1" +serde.workspace = true +serde_json.workspace = true +tokio.workspace = true +tracing-subscriber.workspace = true +tracing.workspace = true diff --git a/src/main.rs b/api/src/main.rs similarity index 73% rename from src/main.rs rename to api/src/main.rs index 399d3be..46e17ae 100644 --- a/src/main.rs +++ b/api/src/main.rs @@ -1,24 +1,17 @@ -use crate::{ - atproto::Nsid, - ingestor::start_ingestor, - router::{ - Router, - Endpoint, - xrpc::{ - QueryInput, - ProcedureInput, - Response, - error, - }, +use crate::router::{ + Router, + Endpoint, + xrpc::{ + QueryInput, + ProcedureInput, + Response, + error, }, }; +use atproto::Nsid; use http::status::StatusCode; -mod atproto; -mod ingestor; -mod lexicons; mod router; -// mod db; #[tokio::main] async fn main() { @@ -30,9 +23,6 @@ async fn main() { let post_nsid = Nsid::new(String::from("me.woach.post")).expect("me.woach.post is a valid nsid"); router = router.add_endpoint(Endpoint::new_xrpc_query(get_nsid, test)); router = router.add_endpoint(Endpoint::new_xrpc_procedure(post_nsid, test2)); - tokio::spawn(async move { - start_ingestor().await; - }); router.serve().await; } diff --git a/src/router.rs b/api/src/router.rs similarity index 91% rename from src/router.rs rename to api/src/router.rs index f6c1b1b..bfa3b17 100644 --- a/src/router.rs +++ b/api/src/router.rs @@ -1,12 +1,10 @@ -use crate::{ - atproto::Nsid, - router::xrpc::{ - XrpcEndpoint, - XrpcHandler, - QueryInput, - ProcedureInput, - } +use crate::router::xrpc::{ + XrpcEndpoint, + XrpcHandler, + QueryInput, + ProcedureInput, }; +use atproto::Nsid; use axum::Router as AxumRouter; use core::net::SocketAddr; use std::net::{IpAddr, Ipv4Addr}; diff --git a/src/router/xrpc.rs b/api/src/router/xrpc.rs similarity index 99% rename from src/router/xrpc.rs rename to api/src/router/xrpc.rs index 3f4c74d..500f331 100644 --- a/src/router/xrpc.rs +++ b/api/src/router/xrpc.rs @@ -1,9 +1,9 @@ -use crate::atproto::Nsid; use std::{ collections::HashMap, pin::Pin, future::Future, }; +use atproto::Nsid; use axum::{ extract::{ Json, diff --git a/atproto/Cargo.toml b/atproto/Cargo.toml index 1cdd783..7d56725 100644 --- a/atproto/Cargo.toml +++ b/atproto/Cargo.toml @@ -6,3 +6,7 @@ edition = "2024" [dependencies] atrium-api = { version = "0.25.3", default-features = false } lazy-regex = "3.4.1" +serde.workspace = true +serde_json.workspace = true +tracing-subscriber.workspace = true +tracing.workspace = true