Skip to content

Commit

Permalink
bump deps and upgrade to rust v1.81
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewmeyer committed Oct 12, 2024
1 parent 0a566c1 commit bd84354
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 44 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on: [push, pull_request]

env:
IMAGE_NAME: sandbox
CARGO_TERM_COLOR: always

jobs:
Expand All @@ -15,29 +14,19 @@ jobs:
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Caching
uses: Swatinem/rust-cache@v2

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt -- --check

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
run: cargo clippy --all-targets --all-features

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
run: cargo test --all-targets --all-features

push-image:
name: Push Image
Expand Down
41 changes: 22 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.75"
async-stripe = { version = "0.25.2", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "connect", "webhook-events", "uuid", "stream", "checkout"] }
axum = { version = "0.6.20", features = ["http2", "headers"] }
chrono = { version = "0.4.31", features = ["serde"] }
dashmap = "5.5.3"
anyhow = "1.0.89"
async-stripe = { version = "0.39.1", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "connect", "webhook-events", "uuid", "stream", "checkout"] }
axum = { version = "0.7.7", features = ["http2"] }
chrono = { version = "0.4.38", features = ["serde"] }
dashmap = "6.1.0"
dotenvy = "0.15.7"
figment = { version = "0.10.12", features = ["env"] }
jsonwebtoken = { version = "9.1.0", default-features = false }
owasp-headers = "0.1.2"
reqwest = { version = "0.11.22", default-features = false, features = ["rustls-tls", "trust-dns"] }
sea-orm = { version = "0.12.7", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros", "with-json", "with-chrono", "with-uuid" ] }
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
serde_with = "3.4.0"
thiserror = "1.0.50"
tokio = { version = "1.34.0", features = ["full"] }
tower = "0.4.13"
tower-default-headers = "0.1.1"
tower-http = { version = "0.4.4", features = ["trace", "cors", "compression-full", "request-id", "timeout"] }
figment = { version = "0.10.19", features = ["env"] }
jsonwebtoken = { version = "9.3.0", default-features = false }
reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls", "trust-dns"] }
sea-orm = { version = "1.0.1", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros", "with-json", "with-chrono", "with-uuid" ] }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
serde_with = "3.11.0"
thiserror = "1.0.64"
tokio = { version = "1.40.0", features = ["full"] }
tower = "0.5.1"
tower-http = { version = "0.6.1", features = ["trace", "cors", "compression-full", "request-id", "timeout", "set-header"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
uuid = { version = "1.6.1", features = ["serde", "v7"] }
uuid = { version = "1.10.0", features = ["serde", "v7"] }

[profile.release]
strip = true
lto = true
codegen-units = 1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.74.0-alpine AS base
FROM rust:1.81.0-alpine AS base
RUN apk add musl-dev musl-utils
RUN cargo install cargo-chef

Expand Down
7 changes: 2 additions & 5 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use sea_orm::{ConnectOptions, Database, DatabaseConnection};
use std::net::{IpAddr, SocketAddr};
use std::sync::Arc;
use tokio::{select, signal};
use tower_default_headers::DefaultHeadersLayer;
use tower_http::compression::CompressionLayer;
use tower_http::cors::CorsLayer;
use tower_http::request_id::{MakeRequestUuid, PropagateRequestIdLayer, SetRequestIdLayer};
Expand Down Expand Up @@ -115,13 +114,11 @@ pub async fn serve(config: Config) -> Result<()> {
.layer(CorsLayer::new())
.layer(PropagateRequestIdLayer::x_request_id())
.layer(SetRequestIdLayer::x_request_id(MakeRequestUuid))
.layer(DefaultHeadersLayer::new(owasp_headers::headers()))
.with_state(state.clone());

info!("Listening on {}", addr);
axum::Server::try_bind(&addr)?
.http1_header_read_timeout(config.request_timeout)
.serve(app.into_make_service())
let listener = tokio::net::TcpListener::bind(&addr).await?;
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal(state.clone()))
.await?;
Ok(())
Expand Down
12 changes: 8 additions & 4 deletions src/api/ratelimit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use std::{
sync::Arc,
};

use axum::{extract::State, http::Request, middleware::Next, response::IntoResponse};
use axum::{
extract::{Request, State},
middleware::Next,
response::IntoResponse,
};

use crate::{error::Error, token_bucket::TokenBucket};

Expand All @@ -12,10 +16,10 @@ use super::ApiContext;
const IP_HEADER: &str = "X-Real-IP";
const DEFAULT_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));

pub async fn limiter<B>(
pub async fn limiter(
State(ctx): State<Arc<ApiContext>>,
req: Request<B>,
next: Next<B>,
req: Request,
next: Next,
) -> Result<impl IntoResponse, Error> {
let ip = req
.headers()
Expand Down

0 comments on commit bd84354

Please sign in to comment.