update api, fix tests and examples

This commit is contained in:
Timur Gordon
2025-08-27 10:07:53 +02:00
parent 767c66fb6a
commit ef17d36300
42 changed files with 2984 additions and 781 deletions

View File

@@ -1,76 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# This script prepares the dev environment and (when sourced) exports env vars.
# Usage:
# source ./scripts/environment.sh # export env vars to current shell
# ./scripts/environment.sh # runs setup checks; prints sourcing hint
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_ROOT=$(cd "$SCRIPT_DIR/.." && pwd)
cd "$REPO_ROOT"
# --- Helper: print next steps -------------------------------------------------
print_next_steps() {
echo ""
echo "Next steps:"
echo " 1) Start server (in ../server): cargo run -- --from-env --verbose"
echo " 2) Start portal: ./scripts/start.sh (or ./scripts/start.sh --port 8088)"
echo " 3) Dev (Trunk): set -a; source .env; set +a; trunk serve"
}
# --- Ensure .env exists (key=value style) -------------------------------------
if [ ! -f ".env" ]; then
echo "📝 Creating .env file..."
cat > .env << EOF
# Portal Client Configuration
# This file configures the frontend portal app
## Export-style so that 'source .env' exports to current shell
# API Key for server authentication (must match one of the API_KEYS in the server .env)
export API_KEY=dev_key_123
# Optional: Override server API base URL (defaults to http://127.0.0.1:3001/api)
# Example: API_URL=http://localhost:3001/api
# export API_URL=
EOF
echo "✅ Created .env file with default API key"
else
echo "✅ .env file already exists"
fi
# --- Install prerequisites ----------------------------------------------------
if ! command -v trunk >/dev/null 2>&1; then
echo "📦 Installing trunk..."
cargo install trunk
else
echo "✅ trunk is installed"
fi
if ! rustup target list --installed | grep -q "wasm32-unknown-unknown"; then
echo "🔧 Adding wasm32-unknown-unknown target..."
rustup target add wasm32-unknown-unknown
else
echo "✅ wasm32-unknown-unknown target present"
fi
# --- Detect if sourced vs executed --------------------------------------------
# Works for bash and zsh
is_sourced=false
# shellcheck disable=SC2296
if [ -n "${ZSH_EVAL_CONTEXT:-}" ]; then
case $ZSH_EVAL_CONTEXT in *:file:*) is_sourced=true;; esac
elif [ -n "${BASH_SOURCE:-}" ] && [ "${BASH_SOURCE[0]}" != "$0" ]; then
is_sourced=true
fi
if $is_sourced; then
echo "🔐 Sourcing .env (export-style) into current shell..."
# shellcheck disable=SC1091
source .env
echo "✅ Environment exported (API_KEY, optional API_URL)"
else
echo " Run 'source ./scripts/environment.sh' or 'source .env' to export env vars to your shell."
print_next_steps
fi