37 lines
879 B
Rust
37 lines
879 B
Rust
mod app;
|
|
mod auth;
|
|
mod config;
|
|
mod db;
|
|
mod graphql;
|
|
mod models;
|
|
mod services;
|
|
|
|
use app::create_router;
|
|
use config::Config;
|
|
use db::{create_pool, run_migrations};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let config = Config::from_env()?;
|
|
let pool = create_pool(&config.database_url).await?;
|
|
|
|
run_migrations(&pool).await?;
|
|
|
|
let router = create_router(pool, config.clone());
|
|
|
|
let listener = tokio::net::TcpListener::bind(&format!("0.0.0.0:{}", config.port)).await?;
|
|
|
|
tracing::info!("GraphQL server running on http://0.0.0.0:{}", config.port);
|
|
tracing::info!(
|
|
"GraphiQL playground: http://0.0.0.0:{}/graphql",
|
|
config.port
|
|
);
|
|
tracing::info!("WebSocket subscriptions: ws://0.0.0.0:{}/ws", config.port);
|
|
|
|
axum::serve(listener, router).await?;
|
|
|
|
Ok(())
|
|
}
|