Create minimum storefront endpoints
This commit is contained in:
parent
59f946ac55
commit
797ba248fb
10 changed files with 1290 additions and 2 deletions
1181
Cargo.lock
generated
Normal file
1181
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -6,3 +6,13 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
decky_api = { version = "0.1.0", path = "./decky_api" }
|
||||
|
||||
# web framework
|
||||
actix-web = "4.2"
|
||||
actix-cors = "0.6"
|
||||
|
||||
[workspace]
|
||||
include = [
|
||||
"decky_api"
|
||||
]
|
||||
|
|
10
decky_api/Cargo.toml
Normal file
10
decky_api/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "decky_api"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
#serde_json = { version = "1.0" }
|
3
decky_api/src/lib.rs
Normal file
3
decky_api/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
mod store_plugin;
|
||||
|
||||
pub use store_plugin::{StorePlugin, StorePluginVersion, StorePluginList};
|
37
decky_api/src/store_plugin.rs
Normal file
37
decky_api/src/store_plugin.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*export interface StorePluginVersion {
|
||||
name: string;
|
||||
hash: string;
|
||||
artifact: string | undefined | null;
|
||||
}
|
||||
|
||||
export interface StorePlugin {
|
||||
id: number;
|
||||
name: string;
|
||||
versions: StorePluginVersion[];
|
||||
author: string;
|
||||
description: string;
|
||||
tags: string[];
|
||||
image_url: string;
|
||||
}*/
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
pub type StorePluginList = Vec<StorePlugin>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct StorePlugin {
|
||||
id: usize,
|
||||
name: String,
|
||||
versions: Vec<StorePluginVersion>,
|
||||
author: String,
|
||||
description: String,
|
||||
tags: Vec<String>,
|
||||
image_url: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct StorePluginVersion {
|
||||
pub name: String,
|
||||
pub hash: String,
|
||||
pub artifact: Option<String>,
|
||||
}
|
2
src/consts.rs
Normal file
2
src/consts.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub const PACKAGE_NAME: &'static str = env!("CARGO_PKG_NAME");
|
||||
pub const PACKAGE_VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
29
src/main.rs
29
src/main.rs
|
@ -1,3 +1,28 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
mod consts;
|
||||
mod not_decky;
|
||||
|
||||
use actix_web::{get, App, HttpResponse, HttpServer, Responder};
|
||||
|
||||
#[get("/version_info")]
|
||||
async fn hello() -> impl Responder {
|
||||
HttpResponse::Ok().body(format!("{} v{}", consts::PACKAGE_NAME, consts::PACKAGE_VERSION))
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
let cors = actix_cors::Cors::default()
|
||||
.allowed_origin("https://steamloopback.host")
|
||||
.allow_any_header()
|
||||
.expose_any_header();
|
||||
|
||||
App::new()
|
||||
.wrap(cors)
|
||||
.service(hello)
|
||||
.service(not_decky::decky_index)
|
||||
.service(not_decky::decky_plugins)
|
||||
})
|
||||
.bind(("0.0.0.0", 22252))?
|
||||
.run()
|
||||
.await
|
||||
}
|
||||
|
|
6
src/not_decky/index.rs
Normal file
6
src/not_decky/index.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
use actix_web::{get, HttpResponse, Responder};
|
||||
|
||||
#[get("/")]
|
||||
pub async fn decky_index() -> impl Responder {
|
||||
HttpResponse::Ok().body("TODO")
|
||||
}
|
5
src/not_decky/mod.rs
Normal file
5
src/not_decky/mod.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
mod index;
|
||||
mod plugins;
|
||||
|
||||
pub use index::decky_index;
|
||||
pub use plugins::decky_plugins;
|
9
src/not_decky/plugins.rs
Normal file
9
src/not_decky/plugins.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use decky_api::StorePluginList;
|
||||
|
||||
use actix_web::{get, web::Json, Responder};
|
||||
|
||||
#[get("/plugins")]
|
||||
pub async fn decky_plugins() -> impl Responder {
|
||||
let plugins: Vec<StorePluginList> = Vec::new();
|
||||
Json(plugins)
|
||||
}
|
Loading…
Reference in a new issue