use rocket::{routes};
use crate::util::constants;


mod util {
    pub mod constants;
    pub mod colored_text;
}

mod endpoints {
    pub mod sensors {
        pub mod data;
    }
}
fn print_debug_info() {
    util::colored_text::print_colored_text_info(&format!("- SERVER INFO:"));
    util::colored_text::print_colored_text_info(&format!(" - API VERSION: {} ", constants::API_VERSION));
    util::colored_text::print_colored_text_info(&format!(" - DB NAME: {} ", constants::DB_NAME));
}

 #[rocket::main]
 async fn main() -> Result<(), rocket::Error> {
    util::colored_text::print_colored_text_brand("> SocioCybereeng ");
    util::colored_text::print_colored_text_project("> Project: Hydroponic Systems ");
    util::colored_text::print_colored_text_info("- [Welcome to ResourceHUB API] ");
    
    if util::constants::IS_DEBUG == true {
        print_debug_info();
    }

    // let mut status = ServerStatus::Online;

    // // Use the colored printing function based on the server status
    // match status {
    //     ServerStatus::Online => {
    //     }
    //     ServerStatus::Offline => {
    //         util::colored_text::print_colored_text_notify("[SERVER_STATUS] The server is stopped.");
    //     }
    //     ServerStatus::Starting => {
    //         util::colored_text::print_colored_text_notify("[SERVER_STATUS] The server is starting.");
    //     }
    //     ServerStatus::Stopping => {
    //         util::colored_text::print_colored_text_notify("[SERVER_STATUS] The server is stopping.");
    //     }
    //     ServerStatus::Error(ref err) => {
    //         util::colored_text::print_colored_text_err(&format!("[SERVER_STATUS] An error occurred: {}", err));
    //     }
    // }

    // Start server
    let _rocket = rocket::build()
        .mount(format!("/api/v{}/", constants::API_VERSION), routes![
            endpoints::sensors::data::create,
            endpoints::sensors::data::get,
            endpoints::sensors::data::get_by_id,
        ])
        .launch()
        .await?;
    Ok(())
 }
 

// #[macro_use] extern crate rocket;
// #[launch]
// fn rocket() -> _ {

    // Create an instance of ServerStatus




