pub mod agent;
pub mod ai;
pub mod auth;
pub mod channel;
pub mod error;
pub mod git;
pub mod issues;
pub mod openapi;
pub mod pull_request;
pub mod search;
pub mod user;
pub mod users;
pub mod workspace;

use actix_web::web::{self, ServiceConfig};

pub fn configure(cfg: &mut ServiceConfig, channel_bus: channel::ChannelBus) {
    cfg.service(
        web::scope("/api/v1")
            .configure(auth::configure)
            .configure(user::configure)
            .configure(users::configure)
            .configure(ai::configure)
            .configure(agent::configure)
            .service(
                web::scope("/workspace")
                    .configure(workspace::configure)
                    .service(
                        web::scope("/{wk}")
                            .configure(workspace::configure_wk)
                            .service(
                                web::scope("/repos")
                                    .configure(git::configure)
                                    .configure(pull_request::configure),
                            )
                            .service(
                                web::scope("/issues")
                                    .configure(issues::configure),
                            )
                            .service(
                                web::scope("/labels")
                                    .configure(issues::configure_labels),
                            )
                            .service(
                                web::scope("/milestones")
                                    .configure(issues::configure_milestones),
                            ),
                    ),
            )
            .service(
                web::scope("/ws")
                    .configure(|cfg| channel::configure(cfg, channel_bus)),
            )
            .service(
                web::resource("/search").route(web::get().to(search::search)),
            ),
    );
}
