Added AI agent to manage metadata
This commit is contained in:
39
furumi-agent/src/web/mod.rs
Normal file
39
furumi-agent/src/web/mod.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
pub mod api;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use axum::{Router, routing::{get, post, put}};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::config::Args;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub pool: PgPool,
|
||||
pub config: Arc<Args>,
|
||||
pub system_prompt: Arc<String>,
|
||||
}
|
||||
|
||||
pub fn build_router(state: Arc<AppState>) -> Router {
|
||||
let api = Router::new()
|
||||
.route("/stats", get(api::stats))
|
||||
.route("/queue", get(api::list_queue))
|
||||
.route("/queue/:id", get(api::get_queue_item).delete(api::delete_queue_item))
|
||||
.route("/queue/:id/approve", post(api::approve_queue_item))
|
||||
.route("/queue/:id/reject", post(api::reject_queue_item))
|
||||
.route("/queue/:id/update", put(api::update_queue_item))
|
||||
.route("/artists/search", get(api::search_artists))
|
||||
.route("/artists", get(api::list_artists))
|
||||
.route("/artists/:id", put(api::update_artist))
|
||||
.route("/artists/:id/albums", get(api::list_albums))
|
||||
.route("/albums/:id", put(api::update_album));
|
||||
|
||||
Router::new()
|
||||
.route("/", get(admin_html))
|
||||
.nest("/api", api)
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
async fn admin_html() -> axum::response::Html<&'static str> {
|
||||
axum::response::Html(include_str!("admin.html"))
|
||||
}
|
||||
Reference in New Issue
Block a user