use axum::Router;

use crate::{
    apps::{auth_app::auth_app, image_app::image_app, sepawa_app::sepawa_app},
    database::db::Db,
    error::CmsError,
};

pub fn main_app(db: Db, verification_endpoint: String) -> Result<Router, CmsError> {
    let router = Router::new();

    let auth_app = auth_app(db.clone(), verification_endpoint)?;
    let image_app = image_app(db.clone())?;
    let sepawa_app = sepawa_app(db.clone())?;

    let router = router.merge(auth_app).merge(image_app).merge(sepawa_app);

    Ok(router)
}
