use crate::noose::user::User; // use super::accounts::create_account; use super::dto::{Account, UserBody, UserQuery}; use super::filter::{validate_body_filter, validate_query_filter}; use super::handler::{create_user, get_account, get_user}; use crate::utils::filter::with_context; use crate::utils::structs::Context; use warp::{Filter, Rejection, Reply}; pub fn routes(context: Context) -> impl Filter + Clone { let cors = warp::cors().allow_any_origin(); let index = warp::path::end().map(|| warp::reply::html("

SNEED!

")); index .or(nip05_get(context.clone())) .or(nip05_create(context.clone())) .with(&cors) } fn well_known(warp_method: M) -> impl Filter + Clone where M: (Filter) + Copy, { warp_method.and(warp::path(".well-known")) } fn nostr_well_known() -> impl Filter + Clone { well_known(warp::get()).and(warp::path("nostr.json")) } fn nip05_get(context: Context) -> impl Filter + Clone { nostr_well_known() .and(validate_query_filter::()) .and(with_context(context.clone())) .and_then(get_user) } fn nip05_create(context: Context) -> impl Filter + Clone { well_known(warp::post()) .and(warp::path("nostr.json")) .and(warp::body::content_length_limit(1024)) .and(validate_body_filter::()) .and(with_context(context.clone())) .and_then(create_user) } // pub fn account_create( // context: Context, // ) -> impl Filter + Clone { // warp::path("account") // .and(warp::post()) // .and(validate_body_filter::()) // .and(with_context(context)) // .and_then(create_account) // } // pub fn account_get( // context: Context, // ) -> impl Filter + Clone { // warp::path("account") // .and(warp::get()) // .and(validate_body_filter::()) // .and(with_context(context)) // .and_then(get_account) // } // pub fn account_update( // context: Context, // ) -> impl Filter + Clone { // warp::path("account") // .and(warp::put()) // .and(warp::body::json::()) // .then(validate_body) // .and(with_context(context)) // .and_then(update_account) // }