pub mod access_token;
pub mod accessibility;
pub mod appearance;
pub mod chpc;
pub mod config;
pub mod notification;
pub mod privacy;
pub mod profile;
pub mod sshkey;

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

pub fn configure(cfg: &mut ServiceConfig) {
    cfg.service(
        web::scope("/user")
            .service(
                web::resource("/notifications")
                    .route(web::get().to(notification::list_notifications)),
            )
            .service(
                web::resource("/config")
                    .route(web::get().to(config::user_config)),
            )
            .service(
                web::resource("/config/accessibility")
                    .route(web::put().to(accessibility::update_accessibility)),
            )
            .service(
                web::resource("/config/appearance")
                    .route(web::put().to(appearance::update_appearance)),
            )
            .service(
                web::resource("/config/notification")
                    .route(web::put().to(notification::update_notification)),
            )
            .service(
                web::resource("/config/privacy")
                    .route(web::put().to(privacy::update_privacy)),
            )
            .service(
                web::resource("/config/profile")
                    .route(web::put().to(profile::update_profile)),
            )
            .service(
                web::resource("/avatar")
                    .route(web::post().to(profile::upload_avatar)),
            )
            .service(
                web::resource("/access-tokens")
                    .route(web::get().to(access_token::list_access_tokens))
                    .route(web::post().to(access_token::create_access_token)),
            )
            .service(
                web::resource("/access-tokens/{id}")
                    .route(web::put().to(access_token::update_access_token))
                    .route(web::delete().to(access_token::revoke_access_token)),
            )
            .service(
                web::resource("/ssh-keys")
                    .route(web::get().to(sshkey::list_ssh_keys))
                    .route(web::post().to(sshkey::add_ssh_key)),
            )
            .service(
                web::resource("/ssh-keys/{id}")
                    .route(web::put().to(sshkey::update_ssh_key))
                    .route(web::delete().to(sshkey::revoke_ssh_key)),
            )
            .service(
                web::resource("/contribution-heatmap")
                    .route(web::get().to(chpc::contribution_heatmap)),
            )
            .service(
                web::resource("/contribution-heatmap/cache")
                    .route(web::delete().to(chpc::invalidate_chpc_cache)),
            ),
    );
}
