2026-02-16 16:24:21 +00:00
|
|
|
mod http;
|
|
|
|
|
mod io;
|
2026-02-13 12:31:36 +00:00
|
|
|
mod llm;
|
|
|
|
|
mod state;
|
|
|
|
|
mod store;
|
|
|
|
|
|
2026-02-16 16:24:21 +00:00
|
|
|
use crate::http::build_routes;
|
|
|
|
|
use crate::http::context::AppContext;
|
2026-02-13 12:31:36 +00:00
|
|
|
use crate::state::SessionState;
|
|
|
|
|
use crate::store::JsonFileStore;
|
2026-02-16 16:24:21 +00:00
|
|
|
use poem::Server;
|
|
|
|
|
use poem::listener::TcpListener;
|
2026-02-13 12:31:36 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
|
|
|
let app_state = Arc::new(SessionState::default());
|
|
|
|
|
let store = Arc::new(
|
|
|
|
|
JsonFileStore::from_path(PathBuf::from("store.json")).map_err(std::io::Error::other)?,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
let ctx = AppContext {
|
|
|
|
|
state: app_state,
|
|
|
|
|
store,
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-16 16:24:21 +00:00
|
|
|
let app = build_routes(ctx);
|
2026-02-13 12:31:36 +00:00
|
|
|
|
|
|
|
|
Server::new(TcpListener::bind("127.0.0.1:3001"))
|
|
|
|
|
.run(app)
|
|
|
|
|
.await
|
|
|
|
|
}
|