//! jpl-website server main entry point

use axum::Router;
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use jpl-website_ssr::App;

#[tokio::main]
async fn main() {
    println!("🚀 Starting jpl-website server...");
    
    let conf = leptos_config::get_configuration(None).unwrap();
    let leptos_options = conf.leptos_options;
    let addr = leptos_options.site_addr;
    
    // Generate the list of routes in your Leptos App
    let routes = generate_route_list(App);
    
    let app = Router::new()
        .leptos_routes(&leptos_options, routes, App)
        .fallback(|| async { "jpl-website - Page not found" });
    
    println!("🌐 jpl-website server running at http://{}", &addr);
    
    let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
    axum::serve(listener, app.into_make_service())
        .await
        .unwrap();
}