make graphQL playground private and add CDN URL variable

This commit is contained in:
Andrea Toska 2025-05-12 11:26:14 +02:00
commit cc20eac02b
No known key found for this signature in database
GPG key ID: 5B3C83807CCBE9A2
3 changed files with 21 additions and 11 deletions

View file

@ -198,16 +198,16 @@ impl Mutation {
} }
*/ */
#[rocket::get("/graphiql")] // #[rocket::get("/graphiql")]
pub fn graphiql() -> RawHtml<String> { // pub fn graphiql() -> RawHtml<String> {
juniper_rocket::graphiql_source("/graphql", None) // juniper_rocket::graphiql_source("/graphql", None)
} // }
//
//
#[rocket::get("/playground")] // #[rocket::get("/playground")]
pub fn playground() -> RawHtml<String> { // pub fn playground() -> RawHtml<String> {
juniper_rocket::playground_source("/graphql", None) // juniper_rocket::playground_source("/graphql", None)
} // }
#[rocket::get("/graphql?<request..>")] #[rocket::get("/graphql?<request..>")]
pub async fn get_graphql( pub async fn get_graphql(

View file

@ -119,6 +119,10 @@ async fn launch() -> _ {
env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str() env::var("S3_PASSWD").expect("S3_PASSWD not specified").into_boxed_str()
); );
pub static CDN_URL: Lazy<Box<str>> = Lazy::new(||
env::var("CDN_URL").expect("CDN_URL not specified").into_boxed_str()
);
let s3_client = ClientBuilder::new(S3_URL.clone()) let s3_client = ClientBuilder::new(S3_URL.clone())
.provider(Some(Box::new(StaticProvider::new(&S3_USER, &S3_PASSWD, None)))) .provider(Some(Box::new(StaticProvider::new(&S3_USER, &S3_PASSWD, None))))
.build() .build()

View file

@ -1,7 +1,13 @@
use std::env;
use once_cell::sync::Lazy;
use rocket::{get}; use rocket::{get};
use crate::account::account::{Auth}; use crate::account::account::{Auth};
use rocket::serde::json::Json; use rocket::serde::json::Json;
pub static CDN_URL: Lazy<Box<str>> = Lazy::new(||
env::var("CDN_URL").expect("CDN_URL not specified").into_boxed_str()
);
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
struct EmailInfo { struct EmailInfo {
address: String, address: String,
@ -89,7 +95,7 @@ pub async fn get_user(auth: Auth<false>) -> Json<UserInfoResponse> {
.map(|v| v.name) .map(|v| v.name)
.unwrap_or_else(|| "INVALID".to_string()) .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 { flags: FlagsInfo {
marketing: user.marketing_allowed, marketing: user.marketing_allowed,