A focused Docker Compose management web application.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: operationId overlap

Brooke 8bd15d89 027c48db

+44 -25
+20 -8
packages/node/src/api/actions.rs
··· 1 1 //! Manages project actions 2 2 3 3 use crate::{api::response::LuminaryResponse, core::LuminaryEngine, obtain}; 4 - use salvo::{Depot, Request, Router, oapi::endpoint}; 4 + use eyre::ContextCompat; 5 + use salvo::{Depot, Request, oapi::endpoint}; 5 6 6 - /// Returns a router containing all action-related endpoints. 7 - pub fn router() -> Router { 8 - return Router::new().push(Router::with_path("restart").post(restart)); 7 + /// Restarts the given project and all its services. 8 + #[endpoint] 9 + pub async fn restart_project(req: &mut Request, depot: &mut Depot) -> LuminaryResponse<()> { 10 + let engine = obtain!(depot, LuminaryEngine); 11 + 12 + let project = req 13 + .param::<String>("project") 14 + .wrap_err("Expected project parameter")?; 15 + 16 + engine.restart(project, None).await?; 17 + return Ok(().into()); 9 18 } 10 19 20 + /// Restarts the given service of the project. 11 21 #[endpoint] 12 - async fn restart(req: &mut Request, depot: &mut Depot) -> LuminaryResponse<()> { 22 + pub async fn restart_service(req: &mut Request, depot: &mut Depot) -> LuminaryResponse<()> { 13 23 let engine = obtain!(depot, LuminaryEngine); 14 24 15 - let service = req.param::<String>("service"); 25 + let service = req 26 + .param::<String>("service") 27 + .wrap_err("Expected service parameter")?; 16 28 let project = req 17 29 .param::<String>("project") 18 - .expect("Expected project parameter"); 30 + .wrap_err("Expected project parameter")?; 19 31 20 - engine.restart(project, service).await?; 32 + engine.restart(project, Some(service)).await?; 21 33 return Ok(().into()); 22 34 }
+23 -16
packages/node/src/api/mod.rs
··· 31 31 .inject(pool); 32 32 33 33 // Set up the app router 34 - let router = Router::new().hoop(affix).push( 35 - Router::with_path("/api") 36 - .push(Router::with_path("ping").get(ping)) 37 - .push(auth::router()) 38 - .push( 39 - Router::new() 40 - .hoop(protected) 41 - .push(Router::with_path("realtime").get(app_subscribe)) 42 - .push( 43 - Router::with_path("/project/{project}") 44 - .push(Router::with_path("logs").get(logs_subscribe)) 45 - .push(actions::router()) 46 - .push(Router::with_path("service/{service}").push(actions::router())), 47 - ), 48 - ), 49 - ); 34 + let router = router().hoop(affix); 50 35 51 36 // Write OpenAPI documentation to file for the panel to consume 52 37 #[cfg(debug_assertions)] ··· 72 57 } 73 58 74 59 return Ok(router); 60 + } 61 + 62 + fn router() -> Router { 63 + return Router::new().push( 64 + Router::with_path("/api") 65 + .push(Router::with_path("ping").get(ping)) 66 + .push(auth::router()) 67 + .push( 68 + Router::new() 69 + .hoop(protected) 70 + .push(Router::with_path("realtime").get(app_subscribe)) 71 + .push( 72 + Router::with_path("/project/{project}") 73 + .push(Router::with_path("logs").get(logs_subscribe)) 74 + .push(Router::with_path("restart").get(actions::restart_project)) 75 + .push( 76 + Router::with_path("service/{service}") 77 + .push(Router::with_path("restart").get(actions::restart_service)), 78 + ), 79 + ), 80 + ), 81 + ); 75 82 } 76 83 77 84 /// A simple endpoint to test if the server is running.
+1 -1
packages/node/src/api/response.rs
··· 32 32 33 33 operation.responses.insert( 34 34 "200", 35 - salvo::oapi::Response::new("Response").add_content( 35 + salvo::oapi::Response::new("Either LuminarySuccess Response or LuminaryFailResponse").add_content( 36 36 "application/json", 37 37 salvo::oapi::Content::new(OneOf::new().item(schema)), 38 38 ),