@@ -22,6 +22,9 @@ use crate::{
2222 models, privacy_classify, rerank, score,
2323 } ,
2424 conversations,
25+ feature_requests:: {
26+ list_admin_feature_requests, submit_feature_request, FeatureRequestsRouteState ,
27+ } ,
2528 health:: health_check,
2629 models:: { get_model_by_name, list_models, ModelsAppState } ,
2730 responses,
@@ -883,6 +886,11 @@ pub fn build_app_with_config(
883886 let files_routes =
884887 build_files_routes ( app_state. clone ( ) , & auth_components. auth_state_middleware ) ;
885888
889+ let feature_request_routes = build_feature_request_routes (
890+ database. pool ( ) . clone ( ) ,
891+ & auth_components. auth_state_middleware ,
892+ ) ;
893+
886894 let billing_routes = build_billing_routes (
887895 domain_services. usage_service . clone ( ) ,
888896 & auth_components. auth_state_middleware ,
@@ -936,6 +944,7 @@ pub fn build_app_with_config(
936944 . merge ( invitation_routes)
937945 . merge ( auth_vpc_routes)
938946 . merge ( files_routes)
947+ . merge ( feature_request_routes)
939948 . merge ( billing_routes)
940949 . merge ( usage_recording_routes)
941950 . merge ( gateway_routes)
@@ -1319,6 +1328,36 @@ pub fn build_files_routes(app_state: AppState, auth_state_middleware: &AuthState
13191328 ) )
13201329}
13211330
1331+ /// Build feature request routes for user submissions and admin aggregation.
1332+ pub fn build_feature_request_routes (
1333+ pool : database:: DbPool ,
1334+ auth_state_middleware : & AuthState ,
1335+ ) -> Router {
1336+ use crate :: middleware:: { admin_middleware, auth_middleware} ;
1337+
1338+ let state = FeatureRequestsRouteState {
1339+ repository : Arc :: new ( database:: repositories:: FeatureRequestRepository :: new ( pool) ) ,
1340+ } ;
1341+
1342+ let user_routes = Router :: new ( )
1343+ . route ( "/feature-requests" , post ( submit_feature_request) )
1344+ . with_state ( state. clone ( ) )
1345+ . layer ( from_fn_with_state (
1346+ auth_state_middleware. clone ( ) ,
1347+ auth_middleware,
1348+ ) ) ;
1349+
1350+ let admin_routes = Router :: new ( )
1351+ . route ( "/admin/feature-requests" , get ( list_admin_feature_requests) )
1352+ . with_state ( state)
1353+ . layer ( from_fn_with_state (
1354+ auth_state_middleware. clone ( ) ,
1355+ admin_middleware,
1356+ ) ) ;
1357+
1358+ Router :: new ( ) . merge ( user_routes) . merge ( admin_routes)
1359+ }
1360+
13221361/// Build billing routes with API key auth (HuggingFace billing integration)
13231362pub fn build_billing_routes (
13241363 usage_service : Arc < dyn services:: usage:: UsageServiceTrait + Send + Sync > ,
0 commit comments