ggen_api/
lib.rs

1//! REST API layer for ggen monetization
2//!
3//! This crate provides HTTP endpoints for:
4//! - Marketplace operations (search, install, purchase)
5//! - User authentication (OAuth, JWT, API keys)
6//! - Billing and usage tracking
7//! - SaaS tier management and quota enforcement
8
9pub mod handlers;
10pub mod middleware;
11pub mod models;
12pub mod routes;
13pub mod state;
14pub mod error;
15
16pub use routes::create_router;
17pub use state::AppState;
18pub use error::ApiError;
19
20use axum::Router;
21use std::sync::Arc;
22use tower_http::cors::CorsLayer;
23use tower_http::trace::TraceLayer;
24
25/// Initialize the API router with all handlers
26pub async fn init_api(state: AppState) -> Router {
27    let cors = CorsLayer::permissive();
28    let trace = TraceLayer::new_for_http();
29
30    Router::new()
31        .nest("/api/v1", create_router(state))
32        .layer(cors)
33        .layer(trace)
34}