Initial commit
ci / docker (backend, backend/Dockerfile, backend) (push) Successful in 21s
ci / docker (frontend, frontend/Dockerfile, frontend) (push) Successful in 23s

This commit is contained in:
2025-10-17 20:19:47 +02:00
commit 2af2af3460
132 changed files with 35408 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
use std::sync::Arc;
use diesel::{
pg::PgConnection,
r2d2::{ConnectionManager, PooledConnection},
};
use crate::{
auth::jwt::JwtService,
config::AppConfig,
db::PgPool,
error::{AppError, AppResult},
storage::ObjectStorage,
};
type PgPooledConnection = PooledConnection<ConnectionManager<PgConnection>>;
#[derive(Clone)]
pub struct AppState {
pub pool: PgPool,
pub config: Arc<AppConfig>,
pub storage: Arc<dyn ObjectStorage>,
pub jwt: JwtService,
}
impl AppState {
pub fn new(
pool: PgPool,
config: AppConfig,
storage: Arc<dyn ObjectStorage>,
jwt: JwtService,
) -> Self {
Self {
pool,
config: Arc::new(config),
storage,
jwt,
}
}
pub fn db(&self) -> AppResult<PgPooledConnection> {
self.pool
.get()
.map_err(|err| AppError::internal(format!("database pool error: {err}")))
}
}