Make lints pass

This commit is contained in:
Andras Schmelczer 2024-12-18 21:54:58 +00:00
parent da0e5f7373
commit 0c92bf959b
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
10 changed files with 30 additions and 20 deletions

View file

@ -24,3 +24,6 @@ schemars = { version = "0.8.21", features = ["chrono", "uuid1"] }
rand = "0.8.5"
axum-extra = { version = "0.9.6", features = ["typed-header"] }
tower-http = { version = "0.6.1", features = ["cors"] }
[lints]
workspace = true

View file

@ -26,6 +26,7 @@ pub enum SyncServerError {
#[error("Unauthorized: {0}")]
Unauthorized(#[source] anyhow::Error),
#[allow(dead_code)]
#[error("Permission denied error: {0}")]
PermissionDeniedError(#[source] anyhow::Error),
}
@ -82,7 +83,9 @@ impl OperationOutput for SyncServerError {
type Inner = Self;
}
pub const fn init_error(error: anyhow::Error) -> SyncServerError { SyncServerError::InitError(error) }
pub const fn init_error(error: anyhow::Error) -> SyncServerError {
SyncServerError::InitError(error)
}
pub fn server_error(error: anyhow::Error) -> SyncServerError {
warn!("Server error: {:?}", error);

View file

@ -1,5 +1,3 @@
#![warn(clippy::all, clippy::restriction, clippy::pedantic, clippy::cargo)]
mod app_state;
mod config;
mod consts;

View file

@ -8,9 +8,9 @@ use aide::{
};
use anyhow::{Context, Result};
use axum::{
extract::{DefaultBodyLimit, WebSocketUpgrade},
extract::DefaultBodyLimit,
http::{self, HeaderValue, Method},
response::{IntoResponse, Response},
response::IntoResponse,
Extension, Json,
};
use log::info;
@ -63,7 +63,6 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
"/vaults/:vault_id/documents/:document_id",
delete(delete_document::delete_document),
)
.api_route("/ws", get(handler))
.route("/", Scalar::new("/api.json").axum_route())
.route("/api.json", axum::routing::get(serve_api))
.layer(DefaultBodyLimit::max(
@ -96,11 +95,4 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
.context("Failed to start server")
}
async fn handler(ws: WebSocketUpgrade) -> Response {
ws.protocols(["graphql-ws", "graphql-transport-ws"])
.on_upgrade(|socket| async {
// ...
})
}
async fn serve_api(Extension(api): Extension<OpenApi>) -> impl IntoResponse { Json(api) }

View file

@ -12,8 +12,8 @@ pub async fn ping(
maybe_auth_header: Option<TypedHeader<Authorization<Bearer>>>,
State(state): State<AppState>,
) -> Result<Json<PingResponse>, SyncServerError> {
let is_authenticated = maybe_auth_header
.is_some_and(|auth_header| auth(&state, auth_header.token()).is_ok());
let is_authenticated =
maybe_auth_header.is_some_and(|auth_header| auth(&state, auth_header.token()).is_ok());
Ok(Json(PingResponse {
server_version: env!("CARGO_PKG_VERSION").to_string(),