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

2
api/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
target/
.env

2997
api/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

13
api/Cargo.toml Normal file
View file

@ -0,0 +1,13 @@
[package]
name = "septastic_api"
version = "0.1.0"
edition = "2024"
[dependencies]
actix-web = "4"
anyhow = "1.0.98"
dotenv = "0.15.0"
env_logger = "0.11.8"
log = "0.4.27"
serde_json = "1.0.140"
sqlx = { version = "0.8.6", features = [ "runtime-async-std", "postgres" ] }

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(())
}