mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-22 00:04:18 +00:00
Setup editor config in server and reformat everything
This commit is contained in:
parent
66384988db
commit
a705e73803
9 changed files with 170 additions and 156 deletions
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||||
|
</state>
|
||||||
|
</component>
|
9
todored/.editorconfig
Normal file
9
todored/.editorconfig
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = true
|
||||||
|
tab_width = 4
|
|
@ -1,13 +1,13 @@
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use axum::routing::{get, post};
|
||||||
|
|
||||||
pub mod task;
|
pub mod task;
|
||||||
pub(crate) mod op;
|
pub(crate) mod op;
|
||||||
mod config;
|
mod config;
|
||||||
mod routes;
|
mod routes;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use std::str::FromStr;
|
|
||||||
use axum::routing::{get, post};
|
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::task::Task;
|
use super::task::Task;
|
||||||
|
|
||||||
/// An operation sent from the client to the server.
|
/// An operation sent from the client to the server.
|
||||||
|
@ -8,7 +9,7 @@ pub enum ClientOperation {
|
||||||
/// Set the board's title.
|
/// Set the board's title.
|
||||||
Title(String),
|
Title(String),
|
||||||
/// Create a new [`Task`], or update or delete the task with the given [`Uuid`].
|
/// Create a new [`Task`], or update or delete the task with the given [`Uuid`].
|
||||||
Task(Option<Uuid>, Option<Task>)
|
Task(Option<Uuid>, Option<Task>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An operation sent from the server to the clients, and stored on the database.
|
/// An operation sent from the server to the clients, and stored on the database.
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use axum::Extension;
|
use axum::Extension;
|
||||||
use axum::extract::{Path, WebSocketUpgrade};
|
use axum::extract::{Path, WebSocketUpgrade};
|
||||||
use axum::extract::ws::{Message, WebSocket};
|
use axum::extract::ws::{Message, WebSocket};
|
||||||
use futures_util::{SinkExt, stream::{StreamExt, SplitSink, SplitStream}};
|
|
||||||
use axum::response::Response;
|
use axum::response::Response;
|
||||||
|
use futures_util::{SinkExt, stream::{SplitSink, SplitStream, StreamExt}};
|
||||||
|
|
||||||
pub(crate) async fn websocket(
|
pub(crate) async fn websocket(
|
||||||
Path(board): Path<String>,
|
Path(board): Path<String>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use axum::{Extension, Json};
|
use axum::{Extension, Json};
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use crate::utils::{RedisConnectOr500, RedisUnwrapOr500, Result};
|
|
||||||
|
|
||||||
|
use crate::utils::{RedisConnectOr500, RedisUnwrapOr500, Result};
|
||||||
|
|
||||||
const MAJOR: u32 = pkg_version::pkg_version_major!();
|
const MAJOR: u32 = pkg_version::pkg_version_major!();
|
||||||
const MINOR: u32 = pkg_version::pkg_version_minor!();
|
const MINOR: u32 = pkg_version::pkg_version_minor!();
|
||||||
|
@ -12,15 +12,13 @@ fn compose_version() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn version(
|
pub async fn version() -> Json<String> {
|
||||||
) -> Json<String> {
|
|
||||||
Json(compose_version())
|
Json(compose_version())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn healthcheck(
|
pub async fn healthcheck(
|
||||||
Extension(rclient): Extension<redis::Client>
|
Extension(rclient): Extension<redis::Client>
|
||||||
) -> Result<Json<String>> {
|
) -> Result<Json<String>> {
|
||||||
|
|
||||||
let mut rconn = rclient.get_connection_or_500().await?;
|
let mut rconn = rclient.get_connection_or_500().await?;
|
||||||
|
|
||||||
log::trace!("Sending PING...");
|
log::trace!("Sending PING...");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// A task that can be displayed on the board.
|
/// A task that can be displayed on the board.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
|
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, StatusCode>;
|
pub type Result<T> = std::result::Result<T, StatusCode>;
|
||||||
|
|
||||||
pub(crate) trait RedisUnwrapOr500<T> {
|
pub(crate) trait RedisUnwrapOr500<T> {
|
||||||
|
@ -11,7 +10,10 @@ pub(crate) trait RedisUnwrapOr500<T> {
|
||||||
impl<T> RedisUnwrapOr500<T> for redis::RedisResult<T> {
|
impl<T> RedisUnwrapOr500<T> for redis::RedisResult<T> {
|
||||||
fn unwrap_or_500_and_log(self) -> Result<T> {
|
fn unwrap_or_500_and_log(self) -> Result<T> {
|
||||||
self
|
self
|
||||||
.map_err(|e| { log::error!("{e:#?}"); e })
|
.map_err(|e| {
|
||||||
|
log::error!("{e:#?}");
|
||||||
|
e
|
||||||
|
})
|
||||||
.or(Err(StatusCode::INTERNAL_SERVER_ERROR))
|
.or(Err(StatusCode::INTERNAL_SERVER_ERROR))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue