Compare commits

..

No commits in common. "83631251089c580eae4d3a80cdf24c99711e1bb3" and "d4a3a71e2fefea88ac4465937d64e0ae11f8e79d" have entirely different histories.

12 changed files with 62 additions and 911 deletions

View file

@ -0,0 +1,14 @@
{
"lexicon": 1,
"id": "me.woach.content.anilist",
"defs": {
"main": {
"type": "object",
"required": ["id"],
"key": "nsid",
"properties": {
"id": { "type": "integer" }
}
}
}
}

View file

@ -1,6 +1,6 @@
{
"lexicon": 1,
"id": "my.spoor.content.media",
"id": "me.woach.content.media",
"defs": {
"main": {
"type": "object",
@ -12,14 +12,14 @@
"minLength": 1,
"items": {
"type": "ref",
"ref": "my.spoor.content.title"
"ref": "me.woach.content.title"
}
},
"durationData": {
"type": "union",
"refs": [
"my.spoor.content.media#television",
"my.spoor.content.media#book"
"me.woach.content.media#television",
"me.woach.content.media#book"
]
},
"posterImage": {

View file

@ -1,17 +1,16 @@
{
"lexicon": 1,
"id": "my.spoor.content.title",
"id": "me.woach.content.title",
"defs": {
"main": {
"type": "object",
"properties": {
"language": {
"type": "string",
"format": "nsid",
"knownValues": [
"my.spoor.content.title#romanization",
"my.spoor.content.title#english",
"my.spoor.content.title#native"
"me.woach.content.title#romanization",
"me.woach.content.title#english",
"me.woach.content.title#native"
]
},
"value": { "type": "string", "minLength": 1 }

View file

@ -1,10 +1,10 @@
{
"lexicon": 1,
"id": "my.spoor.log.activity",
"id": "me.woach.feed.activity",
"defs": {
"main": {
"type": "record",
"description": "A single activity (spoor) for a specific session",
"description": "A single activity log for a specific show",
"key": "tid",
"record": {
"type": "object",
@ -13,15 +13,13 @@
"properties": {
"session": { "type": "ref", "ref": "com.atproto.repo.strongRef" },
"progress": {
"type": "union",
"refs": [
"my.spoor.log.activity#indexProgress"
]
"type": "integer",
"description": "The episode/chapter number for the content consumed."
},
"performedAt": {
"type": "string",
"format": "datetime",
"description": "User-declared timestamp for when they performed the activity. Null implies unknown time."
"description": "User-declared timestamp for when they performed the activity."
},
"createdAt": {
"type": "string",
@ -30,10 +28,6 @@
}
}
}
},
"indexProgress": {
"type": "integer",
"description": "The index of the content consumed. Content must be indexable"
}
}
}

View file

@ -1,6 +1,6 @@
{
"lexicon": 1,
"id": "my.spoor.log.session",
"id": "me.woach.feed.session",
"defs": {
"main": {
"type": "record",
@ -16,9 +16,9 @@
"maxGraphemes": 64,
"maxLength": 640
},
"otherParticipants": {
"participants": {
"type": "array",
"items": { "type": "string", "format": "did" }
"items": { "type": "ref", "ref": "com.atproto.repo.strongRef" }
},
"createdAt": {
"type": "string",

View file

@ -1,30 +0,0 @@
{
"lexicon": 1,
"id": "my.spoor.content.external",
"defs": {
"main": {
"type": "object",
"required": [ "source", "queryable" ],
"key": "nsid",
"properties": {
"source": {
"type": "string",
"description": "An nsid for a specific data source. The domain authority governs how to process the queryable",
"format": "nsid",
"knownValues": [
"my.spoor.content.external#tvdb"
]
},
"queryable": {
"type": "union",
"description": "All the data needed to query the content from the source"
},
"overrides": {
"type": "object",
"description": "User defined overrides for the returned content",
"properties": {}
}
}
}
}
}

830
rust/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,11 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
atrium-api = { version = "0.25.2", default-features = false }
axum = { version = "0.8.3", features = ["json"] }
axum-macros = "0.5.0"
http = "1.3.1"
serde = "1.0.219"
serde_json = "1.0.140"
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio"] }
sqlx = { version = "0.8.5", features = ["runtime-tokio"] }
tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] }

View file

@ -1 +0,0 @@
pub use atrium_api::types::string::Nsid;

View file

@ -1,6 +1,4 @@
use crate::{
atproto::Nsid,
router::{
use crate::router::{
Router,
Endpoint,
xrpc::{
@ -9,21 +7,18 @@ use crate::{
Response,
error,
},
},
};
use http::status::StatusCode;
use axum::http::StatusCode;
mod atproto;
mod router;
mod db;
#[tokio::main]
async fn main() {
let mut router = Router::new();
let get_nsid = Nsid::new(String::from("me.woach.get")).expect("me.woach.get is a valid nsid");
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));
router = router.add_endpoint(Endpoint::new_xrpc_query(String::from("me.woach.get"), test));
router = router.add_endpoint(Endpoint::new_xrpc_procedure(String::from("me.woach.post"), test2));
router.serve().await;
}

View file

@ -1,11 +1,8 @@
use crate::{
atproto::Nsid,
router::xrpc::{
use crate::router::xrpc::{
XrpcEndpoint,
XrpcHandler,
QueryInput,
ProcedureInput,
}
};
use axum::Router as AxumRouter;
use core::net::SocketAddr;
@ -22,13 +19,13 @@ pub enum Endpoint {
Xrpc(XrpcEndpoint),
}
impl Endpoint {
pub fn new_xrpc_query<Q>(nsid: Nsid, query: Q) -> Self
pub fn new_xrpc_query<Q>(nsid: String, query: Q) -> Self
where
Q: XrpcHandler<QueryInput> + Clone
{
Endpoint::Xrpc(XrpcEndpoint::new_query(nsid,query))
}
pub fn new_xrpc_procedure<P>(nsid: Nsid, procedure: P) -> Self
pub fn new_xrpc_procedure<P>(nsid: String, procedure: P) -> Self
where
P: XrpcHandler<ProcedureInput> + Clone
{

View file

@ -1,4 +1,3 @@
use crate::atproto::Nsid;
use std::{
collections::HashMap,
pin::Pin,
@ -27,13 +26,13 @@ use axum::{
};
use serde_json::{Value, json};
enum Path {
Nsid(Nsid),
enum Nsid {
Nsid(String),
NotImplemented,
}
pub struct XrpcEndpoint {
path: Path,
nsid: Nsid,
resolver: MethodRouter,
}
@ -124,12 +123,12 @@ where
}
impl XrpcEndpoint {
pub fn new_query<Q>(nsid: Nsid, query: Q) -> Self
pub fn new_query<Q>(nsid: String, query: Q) -> Self
where
Q: XrpcHandler<QueryInput> + Clone
{
XrpcEndpoint {
path: Path::Nsid(nsid),
nsid: Nsid::Nsid(nsid),
resolver: get(async move | mut parts: Parts | -> Response {
match QueryInput::from_request_parts(&mut parts, &()).await {
Ok(qi) => query.call(qi).await,
@ -139,12 +138,12 @@ impl XrpcEndpoint {
}
}
pub fn new_procedure<P>(nsid: Nsid, procedure: P) -> Self
pub fn new_procedure<P>(nsid: String, procedure: P) -> Self
where
P: XrpcHandler<ProcedureInput> + Clone
{
XrpcEndpoint {
path: Path::Nsid(nsid),
nsid: Nsid::Nsid(nsid),
resolver: post(async move | req: Request | -> Response {
match ProcedureInput::from_request(req, &()).await {
Ok(pi) => procedure.call(pi).await,
@ -155,9 +154,9 @@ impl XrpcEndpoint {
}
pub fn add_to_router(self, router: axumRouter) -> axumRouter {
let path = match self.path {
Path::Nsid(nsid) => &("/xrpc/".to_owned() + nsid.as_str()),
Path::NotImplemented => "/xrpc/{*nsid}",
let path = match self.nsid {
Nsid::Nsid(s) => &("/xrpc/".to_owned() + &s),
Nsid::NotImplemented => "/xrpc/{*nsid}",
};
router.route(path, self.resolver)
@ -173,7 +172,7 @@ impl XrpcEndpoint {
);
XrpcEndpoint {
path: Path::NotImplemented,
nsid: Nsid::NotImplemented,
resolver: get(resolver.clone()).post(resolver),
}
}