From cc20eac02b8f4d1e08a0d3abba6a049881c80da8 Mon Sep 17 00:00:00 2001 From: Andrea Toska Date: Mon, 12 May 2025 11:26:14 +0200 Subject: [PATCH] make graphQL playground private and add CDN URL variable --- src/graphql/mod.rs | 20 ++++++++++---------- src/main.rs | 4 ++++ src/papi/user.rs | 8 +++++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/graphql/mod.rs b/src/graphql/mod.rs index 9b5d593..363d008 100644 --- a/src/graphql/mod.rs +++ b/src/graphql/mod.rs @@ -198,16 +198,16 @@ impl Mutation { } */ -#[rocket::get("/graphiql")] -pub fn graphiql() -> RawHtml { - juniper_rocket::graphiql_source("/graphql", None) -} - - -#[rocket::get("/playground")] -pub fn playground() -> RawHtml { - juniper_rocket::playground_source("/graphql", None) -} +// #[rocket::get("/graphiql")] +// pub fn graphiql() -> RawHtml { +// juniper_rocket::graphiql_source("/graphql", None) +// } +// +// +// #[rocket::get("/playground")] +// pub fn playground() -> RawHtml { +// juniper_rocket::playground_source("/graphql", None) +// } #[rocket::get("/graphql?")] pub async fn get_graphql( diff --git a/src/main.rs b/src/main.rs index 273757d..d895bdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,6 +119,10 @@ async fn launch() -> _ { env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() ); + pub static CDN_URL: Lazy> = Lazy::new(|| + env::var("CDN_URL").expect("CDN_URL not specified").into_boxed_str() + ); + let s3_client = ClientBuilder::new(S3_URL.clone()) .provider(Some(Box::new(StaticProvider::new(&S3_USER, &S3_PASSWD, None)))) .build() diff --git a/src/papi/user.rs b/src/papi/user.rs index 770f786..ccfda69 100644 --- a/src/papi/user.rs +++ b/src/papi/user.rs @@ -1,7 +1,13 @@ +use std::env; +use once_cell::sync::Lazy; use rocket::{get}; use crate::account::account::{Auth}; use rocket::serde::json::Json; +pub static CDN_URL: Lazy> = Lazy::new(|| + env::var("CDN_URL").expect("CDN_URL not specified").into_boxed_str() +); + #[derive(serde::Serialize)] struct EmailInfo { address: String, @@ -89,7 +95,7 @@ pub async fn get_user(auth: Auth) -> Json { .map(|v| v.name) .unwrap_or_else(|| "INVALID".to_string()) }, - image_url: format!("https://cdn.spfn.cc/mii/{}/normal_face.png", user.pid), + image_url: format!("https://{}/mii/{}/normal_face.png", &CDN_URL.to_string(), user.pid), }, flags: FlagsInfo { marketing: user.marketing_allowed,