Move to sqlx

This commit is contained in:
2024-12-25 23:28:22 +01:00
parent 3ee5e51767
commit 8002a93069
28 changed files with 2508 additions and 22526 deletions

View File

@@ -1,5 +1,3 @@
use std::sync::Arc;
use axum::{
http::{self, Request, StatusCode},
middleware::{self, Next},
@@ -8,10 +6,11 @@ use axum::{
Extension, Router,
};
use axum_prometheus::PrometheusMetricLayer;
use sqlx::PgPool;
use tower_http::trace::{self, TraceLayer};
use tracing::Level;
use crate::{config::CONFIG, db::get_prisma_client, prisma::PrismaClient};
use crate::{config::CONFIG, db::get_postgres_pool};
use self::translators::get_translators_router;
use self::{
@@ -26,7 +25,7 @@ pub mod genres;
pub mod sequences;
pub mod translators;
pub type Database = Extension<Arc<PrismaClient>>;
pub type Database = Extension<PgPool>;
async fn auth(req: Request<axum::body::Body>, next: Next) -> Result<Response, StatusCode> {
let auth_header = req
@@ -48,7 +47,7 @@ async fn auth(req: Request<axum::body::Body>, next: Next) -> Result<Response, St
}
pub async fn get_router() -> Router {
let client = Arc::new(get_prisma_client().await);
let client = get_postgres_pool().await;
let (prometheus_layer, metric_handle) = PrometheusMetricLayer::pair();