chore: updates #47
5 changed files with 608 additions and 340 deletions
895
Cargo.lock
generated
895
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
22
Cargo.toml
22
Cargo.toml
|
|
@ -1,36 +1,36 @@
|
|||
[package]
|
||||
name = "huellas"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "AGPL-3.0"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.89"
|
||||
axum = { version = "0.7.7", default-features = false, features = [
|
||||
anyhow = "1.0.96"
|
||||
axum = { version = "0.8.1", default-features = false, features = [
|
||||
"tracing",
|
||||
"tokio",
|
||||
"http1",
|
||||
"http2",
|
||||
] }
|
||||
axum-msgpack = "0.4.0"
|
||||
axum-msgpack = "0.5.0"
|
||||
dotenvy = "0.15.7"
|
||||
futures = { version = "0.3.31", default-features = false }
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
sqlx = { version = "0.8.2", default-features = false, features = [
|
||||
serde = { version = "1.0.218", features = ["derive"] }
|
||||
sqlx = { version = "0.8.3", default-features = false, features = [
|
||||
"macros",
|
||||
"migrate",
|
||||
"runtime-tokio",
|
||||
"sqlite",
|
||||
"tls-rustls",
|
||||
] }
|
||||
tokio = { version = "1.40.0", default-features = false, features = [
|
||||
tokio = { version = "1.43.0", default-features = false, features = [
|
||||
"macros",
|
||||
"rt-multi-thread",
|
||||
"signal",
|
||||
] }
|
||||
tower-http = { version = "0.6.1", default-features = false, features = ["fs"] }
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
|
||||
tower-http = { version = "0.6.2", default-features = false, features = ["fs"] }
|
||||
tracing = "0.1.41"
|
||||
tracing-subscriber = { version = "0.3.19", default-features = false, features = [
|
||||
"env-filter",
|
||||
"fmt",
|
||||
"tracing",
|
||||
|
|
@ -38,4 +38,4 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
|||
] }
|
||||
|
||||
[dev-dependencies]
|
||||
axum-test = { version = "16.2.0", features = ["msgpack"] }
|
||||
axum-test = { version = "17.2.0", features = ["msgpack"] }
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
if ! cargo clippy --all-targets -- -D warnings
|
||||
then
|
||||
echo "There are some clippy issues."
|
||||
exit 1
|
||||
if ! cargo clippy --all-targets -- -D warnings; then
|
||||
echo "There are some clippy issues."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! cargo test
|
||||
then
|
||||
echo "There are some test issues."
|
||||
exit 1
|
||||
if ! cargo nextest run; then
|
||||
echo "There are some test issues."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
11
src/main.rs
11
src/main.rs
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::{Context, Result};
|
||||
use axum::Router;
|
||||
use axum::serve::ListenerExt;
|
||||
use sqlx::sqlite::SqlitePool;
|
||||
use std::net::SocketAddr;
|
||||
use tower_http::services::ServeDir;
|
||||
use tracing::trace;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
mod place;
|
||||
|
|
@ -37,9 +39,14 @@ async fn main() -> Result<()> {
|
|||
let port = str::parse(&port).unwrap_or(3000);
|
||||
let address = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
tracing::debug!("listening on {}", address);
|
||||
let listener = tokio::net::TcpListener::bind(address).await?;
|
||||
let listener = tokio::net::TcpListener::bind(address)
|
||||
.await?
|
||||
.tap_io(|tcp_stream| {
|
||||
if let Err(err) = tcp_stream.set_nodelay(true) {
|
||||
trace!("failed to set TCP_NODELAY on incoming connection: {err:#}");
|
||||
}
|
||||
});
|
||||
axum::serve(listener, app.into_make_service())
|
||||
.tcp_nodelay(true)
|
||||
.with_graceful_shutdown(shutdown_signal())
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use axum::Router;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::http::StatusCode;
|
||||
use axum::routing::{delete, get};
|
||||
use axum::Router;
|
||||
use axum_msgpack::MsgPack;
|
||||
use futures::TryStreamExt;
|
||||
use sqlx::sqlite::SqlitePool;
|
||||
|
|
@ -119,7 +119,7 @@ async fn delete_place(State(pool): State<SqlitePool>, Path(id): Path<i64>) -> Re
|
|||
pub fn places_routes(pool: SqlitePool) -> Router {
|
||||
Router::new()
|
||||
.route("/", get(get_places).put(upsert_place))
|
||||
.route("/:id", delete(delete_place))
|
||||
.route("/{id}", delete(delete_place))
|
||||
.with_state(pool)
|
||||
}
|
||||
|
||||
|
|
@ -129,8 +129,8 @@ mod tests {
|
|||
use crate::place::Place;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use axum::http::StatusCode;
|
||||
use axum::Router;
|
||||
use axum::http::StatusCode;
|
||||
use axum_test::TestServer;
|
||||
use sqlx::sqlite::SqlitePool;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue