initial commit

This commit is contained in:
amp 2025-01-25 14:25:44 +00:00
commit 40f551209b
Signed by: amp
GPG key ID: 76C7199F9BAF8E6A
7 changed files with 974 additions and 0 deletions

51
src/main.rs Normal file
View file

@ -0,0 +1,51 @@
use argh::FromArgs;
use axum::{Json, Router, routing::get};
use serde_json::{Value, json};
use std::net::SocketAddr;
use tracing::info;
mod types;
#[derive(FromArgs)]
/// Official OSAKA server implementation
struct CLIArgs {
/// server host (default: 0.0.0.0)
#[argh(option)]
host: Option<String>,
/// server port (default: 80)
#[argh(option)]
port: Option<u32>,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
let cli_args: CLIArgs = argh::from_env();
let addr: SocketAddr = format!(
"{}:{}",
cli_args.host.unwrap_or("0.0.0.0".to_string()),
cli_args.port.unwrap_or(80)
)
.parse()
.expect("problem parsing arguments into valid socket address. check your config.");
let app = Router::new()
.route("/", get(root))
// .route("/search/{query}", get(query::search));
;
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
info!(
"OSAKA {} is listening on {}",
env!("CARGO_PKG_VERSION_MAJOR"),
addr
);
axum::serve(listener, app).await.unwrap();
Ok(())
}
async fn root() -> Json<Value> {
Json(json!({"version": "0.0.1"}))
}

14
src/types.rs Normal file
View file

@ -0,0 +1,14 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct AnimeShow {
title: String,
seasons: u8,
episodes: u16, // im gonna regret these values 01/28/2024
}
#[derive(Debug, Serialize, Deserialize)]
pub struct AnimeSource {
url: String,
name: String,
}