Skip to content

Commit

Permalink
fix: db connect with options
Browse files Browse the repository at this point in the history
  • Loading branch information
sargon64 committed Jul 29, 2023
1 parent 47e26c6 commit b79ec5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/cdn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ async fn cdn_get(db: web::Data<Database>, path: web::Path<(String, String)>) ->
let db = db.pool.clone();

let (slug, version) = path.into_inner();
dbg!(&slug, &version);
let db_mod = Mods::find()
.filter(entity::mods::Column::Slug.eq(&slug))
.one(&db)
Expand Down
18 changes: 9 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ async fn graphql_route(
req: actix_web::HttpRequest,
payload: actix_web::web::Payload,
data: web::Data<Schema>,
db: web::Data<Database>,
) -> Result<HttpResponse, Error> {
let database = Database {
pool: sea_orm::Database::connect(&std::env::var("DATABASE_URL").unwrap())
.await
.unwrap(),
};
juniper_actix::graphql_handler(&data, &database, req, payload).await
juniper_actix::graphql_handler(&data, &db, req, payload).await
}

#[derive(Clone)]
Expand Down Expand Up @@ -102,9 +98,13 @@ async fn main() -> io::Result<()> {
log::info!("GraphiQL playground: http://localhost:8080/graphiql");
log::info!("Playground: http://localhost:8080/playground");

let db_conn = sea_orm::Database::connect(&std::env::var("DATABASE_URL").unwrap())
.await
.unwrap();
let mut db_conf = sea_orm::ConnectOptions::new(std::env::var("DATABASE_URL").unwrap());

db_conf.max_connections(20);
db_conf.sqlx_logging(true);
db_conf.sqlx_logging_level(log::LevelFilter::Debug);

let db_conn = sea_orm::Database::connect(db_conf).await.unwrap();

let _ = std::fs::create_dir(Path::new("./data/cdn"));

Expand Down

0 comments on commit b79ec5a

Please sign in to comment.