pub mod archive;
pub mod blame;
pub mod blob;
pub mod branch;
pub mod commit;
pub mod commit_status;
pub mod compare;
pub mod contents;
pub mod contributor;
pub mod diff;
pub mod dto;
pub mod fork;
pub mod init;
pub mod language;
pub mod protect;
pub mod readme;
pub mod refs;
pub mod release;
pub mod repo;
pub mod star;
pub mod tag;
pub mod tree;
pub mod watch;
pub mod webhook;

use actix_web::{web, web::ServiceConfig};
pub fn configure(cfg: &mut ServiceConfig) {
    cfg.service(
        web::resource("")
            .route(web::post().to(init::create_repo))
            .route(web::get().to(repo::list_repos)),
    );
    cfg.service(
        web::resource("/clone").route(web::post().to(init::clone_repo)),
    );
    cfg.service(
        web::resource("/{repo}")
            .route(web::get().to(repo::get_repo))
            .route(web::put().to(repo::update_repo))
            .route(web::delete().to(repo::delete_repo)),
    );
    cfg.service(
        web::resource("/{repo}/archive")
            .route(web::post().to(repo::archive_repo)),
    );
    cfg.service(
        web::resource("/{repo}/transfer")
            .route(web::post().to(repo::transfer_repo)),
    );
    cfg.service(
        web::resource("/{repo}/topics")
            .route(web::get().to(repo::get_topics))
            .route(web::put().to(repo::update_topics)),
    );
    cfg.service(
        web::resource("/{repo}/forks")
            .route(web::get().to(fork::list_forks))
            .route(web::post().to(fork::create_fork)),
    );
    cfg.service(
        web::resource("/{repo}/protect")
            .route(web::get().to(protect::list_protects))
            .route(web::post().to(protect::create_protect)),
    );
    cfg.service(
        web::resource("/{repo}/protect/{protect_id}")
            .route(web::put().to(protect::update_protect))
            .route(web::delete().to(protect::delete_protect)),
    );
    cfg.service(
        web::resource("/{repo}/webhooks")
            .route(web::get().to(webhook::list_webhooks))
            .route(web::post().to(webhook::create_webhook)),
    );
    cfg.service(
        web::resource("/{repo}/webhooks/{webhook_id}")
            .route(web::put().to(webhook::update_webhook))
            .route(web::delete().to(webhook::delete_webhook)),
    );
    cfg.service(
        web::resource("/{repo}/webhooks/{webhook_id}/deliveries")
            .route(web::get().to(webhook::list_deliveries)),
    );
    cfg.service(
        web::scope("/{repo}/git")
            .service(
                web::resource("/branches")
                    .route(web::get().to(branch::list_branches))
                    .route(web::post().to(branch::fork_branch)),
            )
            .service(
                web::resource("/branches/{name}")
                    .route(web::get().to(branch::branch_info))
                    .route(web::patch().to(branch::rename_branch))
                    .route(web::delete().to(branch::delete_branch)),
            )
            .service(
                web::resource("/branches/{name}/ahead-behind")
                    .route(web::get().to(branch::ahead_behind)),
            )
            .service(
                web::resource("/branches/{name}/upstream")
                    .route(web::get().to(branch::branch_upstream)),
            )
            .service(
                web::resource("/commits")
                    .route(web::get().to(commit::list_commits)),
            )
            .service(
                web::resource("/commits/history")
                    .route(web::get().to(commit::commit_history)),
            )
            .service(
                web::resource("/commits/{oid}")
                    .route(web::get().to(commit::commit_info)),
            )
            .service(
                web::resource("/commits/walk")
                    .route(web::post().to(commit::commit_walk)),
            )
            .service(
                web::resource("/commits/cherry-pick")
                    .route(web::post().to(commit::cherry_pick)),
            )
            .service(
                web::resource("/blobs")
                    .route(web::post().to(blob::blob_upload)),
            )
            .service(
                web::resource("/blobs/{oid}")
                    .route(web::get().to(blob::blob_info)),
            )
            .service(
                web::resource("/blame").route(web::get().to(blame::blame_file)),
            )
            .service(
                web::resource("/trees/{oid}")
                    .route(web::get().to(tree::tree_entries)),
            )
            .service(
                web::resource("/trees/{tree_oid}/entries")
                    .route(web::get().to(tree::tree_entry_by_path)),
            )
            .service(
                web::resource("/commits/{oid}/tree")
                    .route(web::get().to(tree::tree_entry_by_path_from_commit)),
            )
            .service(web::resource("/diff").route(web::get().to(diff::diff)))
            .service(
                web::resource("/diff/branches")
                    .route(web::get().to(readme::diff_branches)),
            )
            .service(
                web::resource("/tags")
                    .route(web::get().to(tag::list_tags))
                    .route(web::post().to(tag::init_tag)),
            )
            .service(
                web::resource("/tags/{name}")
                    .route(web::get().to(tag::tag_info))
                    .route(web::patch().to(tag::update_tag))
                    .route(web::delete().to(tag::delete_tag)),
            )
            .service(
                web::resource("/archive")
                    .route(web::get().to(archive::archive)),
            )
            .service(
                web::resource("/star")
                    .route(web::get().to(star::star_status))
                    .route(web::post().to(star::star_repo))
                    .route(web::delete().to(star::unstar_repo)),
            )
            .service(
                web::resource("/watch")
                    .route(web::get().to(watch::watch_status))
                    .route(web::post().to(watch::watch_repo))
                    .route(web::delete().to(watch::unwatch_repo)),
            )
            .service(
                web::resource("/contributors")
                    .route(web::get().to(contributor::list_contributors)),
            )
            .service(
                web::resource("/languages")
                    .route(web::get().to(language::get_languages)),
            )
            .service(
                web::resource("/readme")
                    .route(web::get().to(readme::get_readme)),
            )
            .service(
                web::resource("/refs").route(web::get().to(refs::list_refs)),
            ),
    );
    cfg.service(
        web::resource("/{repo}/releases")
            .route(web::get().to(release::list_releases))
            .route(web::post().to(release::create_release)),
    )
    .service(
        web::resource("/{repo}/releases/{id}")
            .route(web::get().to(release::get_release))
            .route(web::patch().to(release::update_release))
            .route(web::delete().to(release::delete_release)),
    )
    .service(
        web::resource("/{repo}/releases/tags/{tag}")
            .route(web::get().to(release::get_release_by_tag))
            .route(web::delete().to(release::delete_release_by_tag)),
    )
    .service(
        web::resource("/{repo}/statuses/{sha}")
            .route(web::post().to(commit_status::create_status)),
    )
    .service(
        web::resource("/{repo}/commits/{sha}/status")
            .route(web::get().to(commit_status::combined_status)),
    )
    .service(
        web::resource("/{repo}/commits/{sha}/statuses")
            .route(web::get().to(commit_status::list_statuses)),
    )
    .service(
        web::resource("/{repo}/compare/{basehead}")
            .route(web::get().to(compare::compare)),
    )
    .service(
        web::resource("/{repo}/contents/{path:.*}")
            .route(web::get().to(contents::get_contents))
            .route(web::post().to(contents::create_contents))
            .route(web::put().to(contents::update_contents))
            .route(web::delete().to(contents::delete_contents)),
    );
}
