|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::{env, net::{IpAddr, SocketAddr}};
|
|
|
|
|
|
|
|
|
|
use axum::{
|
|
|
|
|
routing::get,
|
|
|
|
@ -11,6 +11,7 @@ use sqlx::{SqlitePool, sqlite::SqlitePoolOptions};
|
|
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
|
async fn main() {
|
|
|
|
|
let port = env::var("TTC_PORT").unwrap_or("3000".into()).parse().unwrap();
|
|
|
|
|
let pool = SqlitePoolOptions::new()
|
|
|
|
|
.max_connections(5)
|
|
|
|
|
.connect(env::var("TTC_DATABASE_URL")
|
|
|
|
@ -22,11 +23,11 @@ async fn main() {
|
|
|
|
|
sqlx::migrate!("./migrations").run(&pool).await.unwrap();
|
|
|
|
|
|
|
|
|
|
let app = Router::new()
|
|
|
|
|
.route("/api/ttc/hello", get(|| async { "hello world!" }))
|
|
|
|
|
.route("/api/ttc/pronouns/:user", get(user_pronouns))
|
|
|
|
|
.route("/api/the_third_can/hello", get(|| async { "hello world!" }))
|
|
|
|
|
.route("/api/the_third_can/pronouns/:user", get(user_pronouns))
|
|
|
|
|
.with_state(pool);
|
|
|
|
|
|
|
|
|
|
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
|
|
|
|
|
axum::Server::bind(&SocketAddr::new(IpAddr::from([0;4]), port))
|
|
|
|
|
.serve(app.into_make_service())
|
|
|
|
|
.await
|
|
|
|
|
.unwrap();
|
|
|
|
|