use actix_web::{HttpResponse, web};
use service::AppService;
use session::Session;

use crate::error::ApiError;

fn ok() -> Result<HttpResponse, ApiError> {
    Ok(HttpResponse::Ok().finish())
}

#[utoipa::path(
    post,
    path = "/api/v1/auth/logout",
    responses((status = 200)),
    tag = "auth"
)]
pub async fn logout(
    session: Session,
    service: web::Data<AppService>,
) -> Result<HttpResponse, ApiError> {
    service.auth_logout(&session).await?;
    ok()
}
