119 lines
4.4 KiB
Rust
119 lines
4.4 KiB
Rust
use axum::{Router, middleware, routing::get};
|
|
|
|
use crate::{
|
|
admin::{
|
|
admin_debug_http, admin_get_creation_entry_config, admin_list_database_table_rows,
|
|
admin_list_database_tables, admin_list_tracking_events, admin_login, admin_me,
|
|
admin_overview, admin_upsert_creation_entry_config, require_admin_auth,
|
|
},
|
|
runtime_profile::{
|
|
admin_disable_profile_redeem_code, admin_disable_profile_task_config,
|
|
admin_list_profile_invite_codes, admin_list_profile_recharge_products,
|
|
admin_list_profile_redeem_codes, admin_list_profile_task_configs,
|
|
admin_upsert_profile_invite_code, admin_upsert_profile_recharge_product,
|
|
admin_upsert_profile_redeem_code, admin_upsert_profile_task_config,
|
|
},
|
|
state::AppState,
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route("/admin/api/login", axum::routing::post(admin_login))
|
|
.route(
|
|
"/admin/api/me",
|
|
get(admin_me).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/overview",
|
|
get(admin_overview).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/debug/http",
|
|
axum::routing::post(admin_debug_http).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/tracking/events",
|
|
get(admin_list_tracking_events).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/database/tables",
|
|
get(admin_list_database_tables).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/database/tables/{table_name}/rows",
|
|
get(admin_list_database_table_rows).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/creation-entry/config",
|
|
get(admin_get_creation_entry_config)
|
|
.post(admin_upsert_creation_entry_config)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/redeem-codes",
|
|
get(admin_list_profile_redeem_codes)
|
|
.post(admin_upsert_profile_redeem_code)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/redeem-codes/disable",
|
|
axum::routing::post(admin_disable_profile_redeem_code).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/invite-codes",
|
|
get(admin_list_profile_invite_codes)
|
|
.post(admin_upsert_profile_invite_code)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/tasks",
|
|
get(admin_list_profile_task_configs)
|
|
.post(admin_upsert_profile_task_config)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_admin_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/tasks/disable",
|
|
axum::routing::post(admin_disable_profile_task_config).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_admin_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/admin/api/profile/recharge-products",
|
|
get(admin_list_profile_recharge_products)
|
|
.post(admin_upsert_profile_recharge_product)
|
|
.route_layer(middleware::from_fn_with_state(state, require_admin_auth)),
|
|
)
|
|
}
|