Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect root to mutiny plus website #11

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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