Api, setup. Modified atproto to get here

This commit is contained in:
Julia Lange 2025-05-22 15:43:36 -07:00
parent 6e97eb1899
commit 556b6b3db6
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
7 changed files with 49 additions and 28 deletions

7
Cargo.lock generated
View file

@ -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]]

View file

@ -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"

14
api/Cargo.toml Normal file
View file

@ -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

View file

@ -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;
}

View file

@ -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};

View file

@ -1,9 +1,9 @@
use crate::atproto::Nsid;
use std::{
collections::HashMap,
pin::Pin,
future::Future,
};
use atproto::Nsid;
use axum::{
extract::{
Json,

View file

@ -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