Created Axum routing for localhost, also SQL Table structure

Added a axum router and listener for serving a web page on localhost.
Also a sql table structure was created with sqlx migrate for storing
tickets and users
This commit is contained in:
2026-04-22 13:08:14 +02:00
parent ca54a03d07
commit 9972863232
6 changed files with 2267 additions and 5 deletions

6
.gitignore vendored
View File

@@ -3,13 +3,15 @@
# will have compiled files and executables
debug/
target/
data/
backend/debug/
backend/target/
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
.env
# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore

2230
backend/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,4 +7,5 @@ edition = "2024"
axum = "0.8.9"
serde = { version = "1.0.228", features = ["derive"] }
sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio", "tls-native-tls"] }
tokio = { version = "1.52.1", features = ["tr-multi-thread", "macros"] }
tokio = { version = "1.52.1", features = ["rt-multi-thread", "macros"] }
dotenv = "0.15.0"

View File

@@ -1,3 +1,16 @@
fn main() {
println!("Hello, world!");
use axum::{Router, routing};
use dotenv::dotenv;
use serde::{Deserialize, Serialize};
use sqlx::{PgPool, postgres::PgPoolOptions};
#[tokio::main]
async fn main() {
let app = Router::new().route("/", routing::get(root_handler));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8001").await.unwrap();
axum::serve(listener, app).await;
}
async fn root_handler() -> &'static str {
"Hello, World"
}

View File

@@ -0,0 +1,10 @@
CREATE TYPE category AS ENUM('Whiteboard Beamer', 'Internet', 'iPad Koffer', 'Apple TV', 'Docu Cam', 'Sonstiges')
CREATE TABLE IF NOT EXISTS tickets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
category category NOT NULL DEFAULT 'Sonstiges',
betreff VARCHAR(100),
description VARCHAR,
room SMALLINT,
user_id SMALLINT
);

View File

@@ -0,0 +1,6 @@
CREATE TABLE users (
id SMALLINT PRIMARY KEY AUTOINCREMENT,
name VARCHAR(30),
firstname VARCHAR(30),
is_admin BOOLEAN NOT NULL DEFAULT false
);