Compare commits

..

No commits in common. "master" and "v2.1.1" have entirely different histories.

3 changed files with 276 additions and 237 deletions

481
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package]
name = "kosyncrs"
version = "2.2.0"
version = "2.1.1"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -10,4 +10,4 @@ axum = "0.8.1"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
sqlx = { version = "0.8.3", features = ["runtime-tokio", "postgres"] }
tokio = { version = "1.45.0", features = ["macros", "rt-multi-thread", "signal"] }
tokio = { version = "1.32.0", features = ["macros", "rt-multi-thread"] }

View file

@ -28,7 +28,6 @@ use axum::{
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use sqlx::{PgExecutor, PgPool, postgres::PgPoolOptions};
use tokio::signal;
use std::env;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
@ -89,40 +88,17 @@ async fn main() {
let mut bind_with = "0.0.0.0:".to_owned();
bind_with += &listen_port;
let listener = tokio::net::TcpListener::bind(bind_with).await.unwrap();
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await
.unwrap();
axum::serve(listener, app).await.unwrap();
}
async fn root() -> &'static str {
"KOReader sync server"
"KOreader sync server"
}
async fn version() -> &'static str {
VERSION
}
async fn shutdown_signal() {
let ctrl_c = async {
signal::ctrl_c()
.await
.expect("Failed to install CTRL-C handler");
};
let terminate = async {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("Failed to install Terminate handler")
.recv()
.await;
};
tokio::select! {
_ = ctrl_c => {},
_ = terminate => {},
}
}
async fn create_user(
State(db_pool): State<PgPool>,
Json(payload): Json<User>,