use crate::presentation::handlers::{audit_handler, extract_handler, searxng_handler};
use axum::{routing::get, Router};
#[cfg(feature = "webhook")]
use crate::infrastructure::database::repositories::webhook_repo_impl::WebhookRepoImpl;
#[cfg(feature = "webhook")]
use crate::presentation::handlers::webhook_handler;
#[cfg(feature = "teams")]
use crate::infrastructure::database::repositories::database_geo_restriction_repo::DatabaseGeoRestrictionRepository;
#[cfg(feature = "teams")]
use crate::presentation::handlers::team_handler;
#[cfg(feature = "teams")]
use axum::routing::put;
#[cfg(feature = "auth")]
use crate::presentation::handlers::api_key_handler;
#[cfg(feature = "webhook")]
pub fn register_webhook_routes() -> Router {
Router::new()
.route(
"/v1/webhooks",
axum::routing::post(webhook_handler::create_webhook::<WebhookRepoImpl>),
)
.route(
"/v1/webhooks",
get(webhook_handler::list_webhooks::<WebhookRepoImpl>),
)
}
#[cfg(not(feature = "webhook"))]
pub fn register_webhook_routes() -> Router {
Router::new()
}
#[cfg(feature = "teams")]
pub fn register_extract_routes() -> Router {
Router::new().route(
"/v1/extract",
axum::routing::post(extract_handler::extract::<DatabaseGeoRestrictionRepository>),
)
}
#[cfg(not(feature = "teams"))]
pub fn register_extract_routes() -> Router {
Router::new().route("/v1/extract", axum::routing::post(extract_handler::extract))
}
#[cfg(feature = "teams")]
pub fn register_teams_routes() -> Router {
Router::new()
.route("/v1/teams/me", get(team_handler::get_team_info))
.route("/v1/teams/me/usage", get(team_handler::get_team_usage))
.route(
"/v1/teams/geo-restrictions",
get(team_handler::get_team_geo_restrictions::<DatabaseGeoRestrictionRepository>),
)
.route(
"/v1/teams/geo-restrictions",
put(team_handler::update_team_geo_restrictions::<DatabaseGeoRestrictionRepository>),
)
}
#[cfg(not(feature = "teams"))]
pub fn register_teams_routes() -> Router {
Router::new()
}
pub fn register_audit_routes() -> Router {
Router::new()
.route("/v1/audit/logs", get(audit_handler::get_audit_logs))
.route("/v1/audit/denied", get(audit_handler::get_denied_requests))
}
pub fn register_searxng_routes() -> Router {
Router::new()
.route(
"/v1/searxng/instances",
get(searxng_handler::list_instances),
)
.route("/v1/searxng/pool", get(searxng_handler::get_pool))
.route(
"/v1/searxng/instances/collect",
axum::routing::post(searxng_handler::trigger_collect),
)
}
#[cfg(feature = "auth")]
pub fn register_admin_routes() -> Router {
Router::new().route(
"/v1/admin/api-keys",
axum::routing::post(api_key_handler::create_api_key),
)
}
#[cfg(not(feature = "auth"))]
pub fn register_admin_routes() -> Router {
Router::new()
}