You've already forked pages
forked from didirus/AstralRinth
* Initial Anrok integration * Query cache, fmt, clippy * Fmt * Use payment intent function in edit_subscription * Attach Anrok client, use payments in index_billing * Integrate Anrok with refunds * Bug fixes * More bugfixes * Fix resubscriptions * Medal promotion bugfixes * Use stripe metadata constants everywhere * Pre-fill values in products_tax_identifiers * Cleanup billing route module * Cleanup * Email notification for tax charge * Don't charge tax on users which haven't been notified of tax change * Fix taxnotification.amount templates * Update .env.docker-compose * Update .env.local * Clippy * Fmt * Query cache * Periodically update tax amount on upcoming charges * Fix queries * Skip indexing tax amount on charges if no charges to process * chore: query cache, clippy, fmt * Fix a lot of things * Remove test code * chore: query cache, clippy, fmt * Fix money formatting * Fix conflicts * Extra documentation, handle tax association properly * Track loss in tax drift * chore: query cache, clippy, fmt * Add subscription.id variable * chore: query cache, clippy, fmt * chore: query cache, clippy, fmt
70 lines
1.9 KiB
Rust
70 lines
1.9 KiB
Rust
use labrinth::queue::email::EmailQueue;
|
|
use labrinth::util::anrok;
|
|
use labrinth::{LabrinthConfig, file_hosting, queue};
|
|
use labrinth::{check_env_vars, clickhouse};
|
|
use std::sync::Arc;
|
|
|
|
pub mod api_common;
|
|
pub mod api_v2;
|
|
pub mod api_v3;
|
|
pub mod asserts;
|
|
pub mod database;
|
|
pub mod dummy_data;
|
|
pub mod environment;
|
|
pub mod pats;
|
|
pub mod permissions;
|
|
pub mod scopes;
|
|
pub mod search;
|
|
|
|
// Testing equivalent to 'setup' function, producing a LabrinthConfig
|
|
// If making a test, you should probably use environment::TestEnvironment::build() (which calls this)
|
|
pub async fn setup(db: &database::TemporaryDatabase) -> LabrinthConfig {
|
|
println!("Setting up labrinth config");
|
|
|
|
dotenvy::dotenv().ok();
|
|
|
|
if check_env_vars() {
|
|
println!("Some environment variables are missing!");
|
|
}
|
|
|
|
let pool = db.pool.clone();
|
|
let ro_pool = db.ro_pool.clone();
|
|
let redis_pool = db.redis_pool.clone();
|
|
let search_config = db.search_config.clone();
|
|
let file_host: Arc<dyn file_hosting::FileHost + Send + Sync> =
|
|
Arc::new(file_hosting::MockHost::new());
|
|
let mut clickhouse = clickhouse::init_client().await.unwrap();
|
|
|
|
let maxmind_reader =
|
|
Arc::new(queue::maxmind::MaxMindIndexer::new().await.unwrap());
|
|
|
|
let stripe_client =
|
|
stripe::Client::new(dotenvy::var("STRIPE_API_KEY").unwrap());
|
|
|
|
let anrok_client = anrok::Client::from_env().unwrap();
|
|
let email_queue =
|
|
EmailQueue::init(pool.clone(), redis_pool.clone()).unwrap();
|
|
|
|
labrinth::app_setup(
|
|
pool.clone(),
|
|
ro_pool.clone(),
|
|
redis_pool.clone(),
|
|
search_config,
|
|
&mut clickhouse,
|
|
file_host.clone(),
|
|
maxmind_reader,
|
|
stripe_client,
|
|
anrok_client,
|
|
email_queue,
|
|
false,
|
|
)
|
|
}
|
|
|
|
pub fn get_json_val_str(val: impl serde::Serialize) -> String {
|
|
serde_json::to_value(val)
|
|
.unwrap()
|
|
.as_str()
|
|
.unwrap()
|
|
.to_string()
|
|
}
|