Skip to content

Commit

Permalink
chore: Update dependencies and improve code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Jun 11, 2024
1 parent d1b4008 commit 3220293
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
14 changes: 14 additions & 0 deletions src/extended_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ use rocket_okapi::gen::OpenApiGenerator;
use rocket_okapi::request::RequestHeaderInput;
use rocket_okapi::OpenApiError;

/// # ExtendedRequest
///
/// This struct is used to extend the Request struct from Rocket adding a headers field.
/// this is needed for analysis of the headers in the request. Particularly useful for
/// retrieving the host with utils::get_host::get_host()
#[derive(Debug)]
pub struct ExtendedRequest{
pub headers: HashMap<String, String>,
}

/// # FromRequest for ExtendedRequest
///
/// This implementation of FromRequest is used to create an ExtendedRequest from a Rocket Request.
#[rocket::async_trait]
impl<'r> FromRequest<'r> for ExtendedRequest {
type Error = Infallible;
Expand All @@ -38,6 +47,11 @@ impl<'r> FromRequest<'r> for ExtendedRequest {
}
}

/// # OpenApiFromRequest for ExtendedRequest
///
/// This implementation of OpenApiFromRequest is used to create an OpenApi RequestHeaderInput from a Rocket Request.
/// This is used to generate the OpenAPI documentation for the request.
///
impl OpenApiFromRequest<'_> for ExtendedRequest {
fn from_request_input(_: &mut OpenApiGenerator, _: std::string::String, _: bool) -> Result<RequestHeaderInput, OpenApiError> {
Ok(RequestHeaderInput::None)
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,16 @@ async fn software_version() -> Json<SoftwareVersionResponse> {
///
/// Returns in the location header the URL of the latest release.
/// something like https://api-server/api/releases/tag/1.2.6
///
/// ## Example
///
/// It is easy to modify the client code to use this API endpoint.
/// this is how we can modify the client code to use this API endpoint.
/// ```rust
/// // see https://github.com/sctg-development/sctgdesk/blob/481d3516fef1daa145d8044594187cb11959f8be/src/common.rs#L953L972
/// let url=format!("{}/api/software/releases/latest",get_api_server("".to_owned(), "".to_owned())).to_owned();
/// log::info!("URL for checking software updates: {}", url);
/// ```
#[openapi(tag = "software")]
#[get("/api/software/releases/latest")]
async fn software_releases_latest(
Expand Down
46 changes: 23 additions & 23 deletions webconsole/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"create-cert": "openssl req -x509 -newkey rsa:4096 -keyout localhost.key -out localhost.pem -sha256 -nodes -days 365",
"preview": "vite preview",
"devserver": "npx nodemon -V -w ./src -e js,vue,ts,css,html --exec 'npm run build && node devserver.js'",
"build": "vite build && gulp licenses"
"build": "vite build && gulp licenses",
"dev": "vite",
"devserver": "npx nodemon -V -w ./src -e js,vue,ts,css,html --exec 'npm run build && node devserver.js'"
},
"dependencies": {
"@pqina/flip": "^1.8.3",
"pinia": "^2.1.7",
"jdenticon": "^3.3.0",
"@heroicons/vue": "^2.1.3",
"jdenticon": "^3.3.0",
"axios": "^1.7.2",
"vue": "^3.4.27",
"pinia": "^2.1.7",
"vue-router": "^4.3.2",
"@headlessui/vue": "^1.7.22",
"vue-router": "^4.3.2"
"@pqina/flip": "^1.8.3",
"vue": "^3.4.27"
},
"devDependencies": {
"sass": "^1.77.2",
"vite": "^5.2.11",
"@fullhuman/postcss-purgecss": "^6.0.0",
"postcss": "^8.4.38",
"express": "^4.19.2",
"postcss-purgefonts": "^1.0.2",
"autoprefixer": "^10.4.19",
"typescript": "^5.4.5",
"npm-check-updates": "^16.14.20",
"vite-plugin-static-copy": "^1.0.5",
"nodemon": "^3.1.0",
"gulp-if": "^3.0.0",
"tailwindcss": "^3.4.3",
"@tailwindcss/forms": "^0.5.7",
"gulp-append-prepend": "^1.0.9",
"@types/glob": "^8.1.0",
"@tailwindcss/typography": "^0.5.13",
"glob": "10.4.1",
"postcss": "^8.4.38",
"ts-node": "^10.9.2",
"nodemon": "^3.1.0",
"@types/glob": "^8.1.0",
"express": "^4.19.2",
"vite-plugin-static-copy": "^1.0.5",
"@tailwindcss/forms": "^0.5.7",
"@fullhuman/postcss-purgecss": "^6.0.0",
"vite": "^5.2.11",
"autoprefixer": "^10.4.19",
"@vitejs/plugin-vue": "^5.0.4",
"gulp": "^5.0.0"
"gulp": "^5.0.0",
"typescript": "^5.4.5",
"npm-check-updates": "^16.14.20",
"ts-node": "^10.9.2",
"sass": "^1.77.2",
"tailwindcss": "^3.4.3"
}
}

0 comments on commit 3220293

Please sign in to comment.