Generic ParameterInput, createAccount xrpc parsing
This commit is contained in:
parent
031faf7db1
commit
6d45fb2f70
2 changed files with 58 additions and 34 deletions
|
|
@ -1,15 +1,28 @@
|
|||
use router::{
|
||||
Router,
|
||||
Endpoint,
|
||||
xrpc::{
|
||||
QueryInput,
|
||||
XrpcEndpoint,
|
||||
ProcedureInput,
|
||||
Response,
|
||||
error,
|
||||
},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use atproto::types::Nsid;
|
||||
use http::status::StatusCode;
|
||||
use tracing::{
|
||||
event,
|
||||
instrument,
|
||||
Level,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
|
||||
struct Config {
|
||||
entryway_url: String,
|
||||
entryway_did: String,
|
||||
entryway_plc_rotation_key: String,
|
||||
entryway_jwt_key_256_hex: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
|
|
@ -17,17 +30,27 @@ async fn main() {
|
|||
let _ = tracing::subscriber::set_global_default(subscriber);
|
||||
|
||||
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));
|
||||
let create_account_nsid: Nsid = "com.atproto.server.createAccount".parse::<Nsid>().expect("valid nsid");
|
||||
router = router.add_endpoint(XrpcEndpoint::new_procedure(create_account_nsid, create_account));
|
||||
router.serve().await;
|
||||
}
|
||||
|
||||
// async fn test(_data: QueryInput) -> Response {
|
||||
// error(StatusCode::OK, "error", "message")
|
||||
// }
|
||||
//
|
||||
// async fn test2(_data: ProcedureInput) -> Response {
|
||||
// error(StatusCode::OK, "error", "message")
|
||||
// }
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct CreateAccountInput {
|
||||
email: Option<String>,
|
||||
handle: String,
|
||||
did: Option<String>,
|
||||
invite_code: Option<String>,
|
||||
verification_code: Option<String>,
|
||||
verification_phone: Option<String>,
|
||||
password: Option<String>,
|
||||
recovery_key: Option<String>,
|
||||
plc_op: Option<String>,
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn create_account(data: ProcedureInput<CreateAccountInput>) -> Response {
|
||||
event!(Level::INFO, "In create_account");
|
||||
|
||||
error(StatusCode::OK, "error", "message")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue