1
0
Fork 0
forked from gorb/backend

feat: add bunny-api-tokio

This commit is contained in:
Radical 2025-05-20 14:54:34 +02:00
parent a676962316
commit cf333b4eba
3 changed files with 53 additions and 3 deletions

View file

@ -25,9 +25,10 @@ struct Args {
pub struct Data {
pub pool: Pool<Postgres>,
pub cache_pool: redis::Client,
pub _config: Config,
pub config: Config,
pub argon2: Argon2<'static>,
pub start_time: SystemTime,
pub bunny_cdn: bunny_api_tokio::Client,
}
#[tokio::main]
@ -48,6 +49,10 @@ async fn main() -> Result<(), Error> {
let cache_pool = redis::Client::open(config.cache_database.url())?;
let mut bunny_cdn = bunny_api_tokio::Client::new(config.bunny.api_key.clone()).await?;
bunny_cdn.storage.init(config.bunny.endpoint.clone(), config.bunny.storage_zone.clone())?;
/*
TODO: Figure out if a table should be used here and if not then what.
Also figure out if these should be different types from what they currently are and if we should add more "constraints"
@ -94,7 +99,8 @@ async fn main() -> Result<(), Error> {
uuid uuid PRIMARY KEY NOT NULL,
owner_uuid uuid NOT NULL REFERENCES users(uuid),
name VARCHAR(100) NOT NULL,
description VARCHAR(300)
description VARCHAR(300),
icon VARCHAR(100) DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS guild_members (
uuid uuid PRIMARY KEY NOT NULL,
@ -164,10 +170,11 @@ async fn main() -> Result<(), Error> {
let data = Data {
pool,
cache_pool,
_config: config,
config,
// TODO: Possibly implement "pepper" into this (thinking it could generate one if it doesnt exist and store it on disk)
argon2: Argon2::default(),
start_time: SystemTime::now(),
bunny_cdn,
};
HttpServer::new(move || {