Skip to content

Commit

Permalink
Merge pull request #11 from MutinyWallet/redirect
Browse files Browse the repository at this point in the history
Redirect root to mutiny plus website
  • Loading branch information
benthecarman authored Mar 27, 2024
2 parents a249487 + e88fc80 commit edc2f42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
mint::{setup_multimint, MultiMintWrapperTrait},
routes::{
check_username, health_check, lnurl_callback_route, lnurl_verify_route, register_route,
valid_origin, validate_cors, well_known_lnurlp_route, well_known_nip5_route,
root, valid_origin, validate_cors, well_known_lnurlp_route, well_known_nip5_route,
},
};

Expand Down Expand Up @@ -112,7 +112,7 @@ async fn main() -> anyhow::Result<()> {
);

// nostr
let nostr_nsec_str = std::env::var("NSEC").expect("FM_DB_PATH must be set");
let nostr_nsec_str = std::env::var("NSEC").expect("NSEC must be set");
let nostr_sk = Keys::from_sk_str(&nostr_nsec_str).expect("Invalid NOSTR_SK");
let nostr = nostr_sdk::Client::new(&nostr_sk);
nostr.add_relay("wss://nostr.mutinywallet.com").await?;
Expand All @@ -122,7 +122,7 @@ async fn main() -> anyhow::Result<()> {

// domain
let domain = std::env::var("DOMAIN_URL")
.expect("DATABASE_URL must be set")
.expect("DOMAIN_URL must be set")
.to_string();

let db = setup_db(pg_url);
Expand Down Expand Up @@ -163,6 +163,7 @@ async fn main() -> anyhow::Result<()> {
};

let server_router = Router::new()
.route("/", get(root))
.route("/health-check", get(health_check))
.route("/v1/check-username/:username", get(check_username))
.route("/v1/register", post(register_route))
Expand Down
5 changes: 5 additions & 0 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use log::{debug, error};
use nostr::prelude::XOnlyPublicKey;
use serde::{de, Deserialize, Deserializer, Serialize};
use std::{collections::HashMap, fmt::Display, str::FromStr};
use axum::response::Redirect;
use tbs::AggregatePublicKey;
use url::Url;

Expand Down Expand Up @@ -214,6 +215,10 @@ pub async fn health_check() -> Result<Json<HealthResponse>, (StatusCode, String)
Ok(Json(HealthResponse::new_ok()))
}

pub async fn root() -> Redirect {
Redirect::to("https://plus.mutinywallet.com")
}

pub fn valid_origin(origin: &str) -> bool {
ALLOWED_ORIGINS.contains(&origin)
|| origin.ends_with(ALLOWED_SUBDOMAIN)
Expand Down

0 comments on commit edc2f42

Please sign in to comment.