multi-hotel-refactor #3
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
|
/.vscode
|
||||||
|
|
||||||
|
|
||||||
.env
|
.env
|
||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal 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"]
|
||||||
@@ -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)]
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
25
src/main.rs
25
src/main.rs
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user