init commit

This commit is contained in:
Nicholas Orlowsky 2025-07-06 20:49:07 -04:00
parent d4b364716f
commit 4466021f07
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
18 changed files with 4734 additions and 2 deletions

40
api/src/main.rs Normal file
View file

@ -0,0 +1,40 @@
use actix_web::{get, App, HttpResponse, HttpServer, Responder};
use env_logger::Env;
use log::*;
use dotenv::dotenv;
use serde_json::json;
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().json("{}")
}
#[actix_web::main]
async fn main() -> ::anyhow::Result<()> {
env_logger::init_from_env(Env::default().default_filter_or("septastic_api=info"));
dotenv().ok();
let version: &str = option_env!("CARGO_PKG_VERSION").expect("Expected package version");
info!("Starting SEPTASTIC Server v{} (commit: {})", version, "NONE");
info!("Connecting to postgres database");
let connection_string =
std::env::var("DB_CONNSTR").expect("Expected database connection string");
let pool = ::sqlx::postgres::PgPoolOptions::new()
.max_connections(5)
.connect(&connection_string)
.await?;
let mut transaction = pool.begin().await?;
HttpServer::new(|| {
App::new()
.service(hello)
})
.bind(("127.0.0.1", 8080))?
.run()
.await?;
Ok(())
}