feat: a bunch of things
This commit is contained in:
parent
2cd0311a20
commit
2e2b01990e
20 changed files with 16216 additions and 137 deletions
46
src/main.rs
46
src/main.rs
|
|
@ -1,26 +1,60 @@
|
|||
use std::env;
|
||||
use diesel::{Connection, MysqlConnection};
|
||||
use std::sync::Arc;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use dotenvy::dotenv;
|
||||
use log::info;
|
||||
use rocket::fairing::AdHoc;
|
||||
use rocket::http::Header;
|
||||
use rocket::routes;
|
||||
use sqlx::Postgres;
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
|
||||
mod xml;
|
||||
mod conntest;
|
||||
mod db;
|
||||
mod nnid;
|
||||
mod account;
|
||||
mod error;
|
||||
mod dsresponse;
|
||||
|
||||
type Pool = sqlx::Pool<Postgres>;
|
||||
|
||||
#[rocket::launch]
|
||||
async fn launch() -> _ {
|
||||
dotenv().ok();
|
||||
|
||||
let act_database_url = env::var("ACCOUNT_DATABASE_URL").expect("account database url is not set");
|
||||
|
||||
let conn = MysqlConnection::establish(&act_database_url).expect("unable to connect to database");
|
||||
|
||||
let act_database_url = env::var("DATABASE_URL").expect("account database url is not set");
|
||||
|
||||
let pool = PgPoolOptions::new()
|
||||
.max_connections(5)
|
||||
.connect(&act_database_url).await
|
||||
.expect("unable to create pool");
|
||||
|
||||
rocket::build()
|
||||
.manage(pool)
|
||||
.attach(AdHoc::on_response("org", |_, response| Box::pin(async move {
|
||||
response.adjoin_header(Header::new("x-organization", "Nintendo"));
|
||||
//response.adjoin_header(Header::new("x-organization", "Nintendo"));
|
||||
response.adjoin_header(Header::new("x-nintendo-date", SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis()
|
||||
.to_string()
|
||||
));
|
||||
|
||||
response.adjoin_header(Header::new("Content-Type", "text/xml; charset=utf-8"));
|
||||
|
||||
|
||||
response.remove_header("x-content-type-options");
|
||||
response.remove_header("x-frame-options");
|
||||
response.remove_header("permissions-policy");
|
||||
})))
|
||||
.mount("/", routes![conntest::conntest])
|
||||
.mount("/", routes![
|
||||
conntest::conntest,
|
||||
nnid::devices::current_device_status,
|
||||
nnid::agreements::get_agreement,
|
||||
nnid::timezones::get_timezone,
|
||||
nnid::person_exists::person_exists,
|
||||
nnid::email::validate
|
||||
])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue