Use a cargo workspace for better modularity

Currently, there is only a `gateway` crate, but in the future,
likely more will be added to handle db stuff, abstractions, etc once
I actually start implementing the city portal logic itself.
This commit is contained in:
Zeph Levy 2025-10-19 14:43:18 +02:00
parent b2384d2e76
commit 4faedce5c6
8 changed files with 157 additions and 214 deletions

View file

@ -1,44 +1,3 @@
mod models;
mod resolvers;
mod schema;
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
use axum::{
Router,
routing::{get, post},
};
use schema::build_schema;
use std::net::SocketAddr;
#[tokio::main]
async fn main() {
let schema = build_schema();
let app = Router::new()
.route(
"/graphql",
post({
let schema = schema.clone();
move |req: GraphQLRequest| async move {
GraphQLResponse::from(schema.execute(req.into_inner()).await)
}
}),
)
.route(
"/graphql",
get({
let schema = schema.clone();
move || async move { axum::Json(schema.sdl()) }
}),
);
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
println!("listening on http://{}", addr);
axum::serve(
tokio::net::TcpListener::bind(addr).await.unwrap(),
app.into_make_service(),
)
.await
.unwrap();
fn main() {
gateway::start();
}