my-app 0.1.0

A web application providing user management and authentication
Documentation
use actix_web::{web, App, HttpServer, middleware};
use sqlx::postgres::PgPoolOptions;
use log::{info, debug};
use my_app::{
    utils::logger,
    account,
};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    // 로깅 설정
    logger::setup_logger();
    info!("서버 시작 준비");

    // 데이터베이스 연결
    debug!("데이터베이스 연결 시도");
    let pool = PgPoolOptions::new()
        .max_connections(5)
        .connect("postgres://user:password@db:5432/mydatabase")
        .await
        .expect("Failed to create pool");
    info!("데이터베이스 연결 성공");

    // 마이그레이션 실행cargo doc --no-deps --open
    debug!("데이터베이스 마이그레이션 시작");
    sqlx::migrate!("./migrations")
        .run(&pool)
        .await
        .expect("Failed to migrate database");
    info!("데이터베이스 마이그레이션 완료");

    info!("Starting server at http://localhost:8080");

    HttpServer::new(move || {
        App::new()
            .app_data(web::Data::new(pool.clone()))
            .wrap(middleware::Logger::default())
            .wrap(middleware::Compress::default())
            // 여기에 라우트 추가
            .configure(account::init_routes) // account 모듈의 라우트 초기화
    })
    .bind("0.0.0.0:8080")?
    .run()
    .await
}