multi-hotel-refactor #3

Merged
Rominou merged 27 commits from multi-hotel-refactor into master 2026-03-11 13:32:43 +00:00
5 changed files with 38 additions and 15 deletions
Showing only changes of commit 96dae54411 - Show all commits

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
/target /target
/.vscode
.env .env

23
Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
FROM rust:latest AS builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
# Create the app user with UID 1001
RUN useradd -u 1001 -m appuser
# Create working directory (only needed if your app expects /app)
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/target/release/hotel-api-rs /usr/local/bin/hotel-api-rs
# Switch to non-root user
USER 1001
# Expose API port
EXPOSE 8080
CMD ["/usr/local/bin/hotel-api-rs"]

View File

@@ -3,7 +3,6 @@ use axum::{
extract::{FromRequest, Request}, extract::{FromRequest, Request},
http::StatusCode, http::StatusCode,
}; };
use chrono::NaiveDateTime;
use serde::Deserialize; use serde::Deserialize;
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]

View File

@@ -208,7 +208,7 @@ pub struct Get
pub async fn get_conv_users( pub async fn get_conv_users(
State(state): State<AppState>, State(state): State<AppState>,
AuthClaims { user_id, hotel_id }: AuthClaims, AuthClaims { user_id, hotel_id }: AuthClaims,
Path(conv_id): Path<(i32)>, Path(conv_id): Path<i32>,
) -> impl IntoResponse { ) -> impl IntoResponse {
let pool = state.hotel_pools.get_pool(hotel_id); let pool = state.hotel_pools.get_pool(hotel_id);

View File

@@ -4,25 +4,14 @@ use axum::extract::{
ws::{Message, WebSocket, WebSocketUpgrade}, ws::{Message, WebSocket, WebSocketUpgrade},
}; };
use axum::serve; use axum::serve;
use jsonwebtoken::{DecodingKey, EncodingKey}; use jsonwebtoken::{DecodingKey, EncodingKey};
use reqwest::header::AUTHORIZATION; use reqwest::header::AUTHORIZATION;
use reqwest::header::CONTENT_TYPE; use reqwest::header::CONTENT_TYPE;
use reqwest::header::USER_AGENT; use reqwest::header::USER_AGENT;
use tokio::net::TcpListener; use tokio::net::TcpListener;
mod chat;
mod inventory;
mod rooms;
mod routes;
mod utils;
use dashmap::DashMap;
use r2d2::Pool;
use r2d2_sqlite::SqliteConnectionManager;
use std::sync::Arc;
use crate::utils::auth::JwtKeys; use crate::utils::auth::JwtKeys;
use crate::utils::db_pool::{AppState, HotelPool}; use crate::utils::db_pool::{AppState, HotelPool};
use routes::create_router; use routes::create_router;
@@ -33,6 +22,16 @@ use std::env;
use axum::http::{HeaderValue, Method}; use axum::http::{HeaderValue, Method};
use tower_http::cors::{Any, CorsLayer}; use tower_http::cors::{Any, CorsLayer};
mod chat;
mod inventory;
mod rooms;
mod routes;
mod utils;
use dashmap::DashMap;
use r2d2::Pool;
use r2d2_sqlite::SqliteConnectionManager;
use std::sync::Arc;
pub async fn notify_discord(msg: &str) -> Result<(), reqwest::Error> { pub async fn notify_discord(msg: &str) -> Result<(), reqwest::Error> {
let payload = serde_json::json!({ let payload = serde_json::json!({
"content": msg "content": msg