Implement auth, persistence, typed responses, and injectable RNG

Auth: JWT tokens (sb-auth) with argon2 password hashing, login/register
endpoints, Bearer token middleware protecting all routes except auth.
Authorization checks ensure users can only access their own characters.

Persistence: SQLite via rusqlite (sb-db) with write-through on all
mutations. Optional via SB_DB_PATH env var; falls back to in-memory.

Typed responses: ~20 response DTOs in sb-shared replacing ad-hoc JSON.

Combat: Injectable RNG via &mut impl Rng for deterministic tests.

Clean Architecture: Combat types and response DTOs in sb-shared; domain
services in sb-core; auth in sb-auth; persistence in sb-db.
This commit is contained in:
Jan-Peter von Hunnius 2026-08-09 16:51:52 +02:00
parent 7a75a523f0
commit 6410e0a86d
39 changed files with 3450 additions and 48 deletions

View file

@ -1,13 +1,34 @@
pub mod mod;
use sb_shared::Item;
use sb_common::PROJECT_NAME;
const WEAPONS_JSON: &str =
include_str!("../../../../skara-brae-common/data/items/weapons.json");
const ARMOR_JSON: &str =
include_str!("../../../../skara-brae-common/data/items/armor.json");
const ACCESSORIES_JSON: &str =
include_str!("../../../../skara-brae-common/data/items/accessories.json");
const WEAPONS: &str = include_str!("../../../../skara-brae-common/data/items/weapons.json");
pub fn load_all_items() -> Vec<Item> {
let mut items = Vec::new();
pub fn game_name() -> &'static str {
PROJECT_NAME
let weapons: Vec<Item> =
serde_json::from_str(WEAPONS_JSON).expect("failed to parse weapons.json");
items.extend(weapons);
let armor: Vec<Item> =
serde_json::from_str(ARMOR_JSON).expect("failed to parse armor.json");
items.extend(armor);
let accessories: Vec<Item> =
serde_json::from_str(ACCESSORIES_JSON).expect("failed to parse accessories.json");
items.extend(accessories);
items
}
pub fn load_weapons() -> Vec<serde_json::Value> {
serde_json::from_str(WEAPONS).expect("failed to parse weapons data")
pub fn item_price(item: &Item) -> i32 {
item.value
}
pub fn item_sell_price(item: &Item) -> i32 {
item.value / 2
}