cc-libs/just/server.just

19 lines
973 B
Plaintext

# Serve the trapos-server gateway (port 4444) for remote/in-game attachment using
# repo-local .env secrets. Mirrors `opencode-serve`, but auth is optional: an unset
# TRAPOS_SERVER_PASSWORD means the gateway runs with auth disabled (warn, do not fail).
[positional-arguments]
serve *args:
#!/usr/bin/env bash
set -euo pipefail
repo='{{justfile_directory()}}'
if [ -f "$repo/.env" ]; then set -a; . "$repo/.env"; set +a; fi
if [ -z "${TRAPOS_SERVER_PASSWORD:-}" ]; then
printf '%s\n' 'serve: TRAPOS_SERVER_PASSWORD unset in .env — gateway auth disabled' >&2
fi
export TRAPOS_SERVER_PASSWORD="${TRAPOS_SERVER_PASSWORD:-}"
export OPENCODE_SERVER_PASSWORD="${OPENCODE_SERVER_PASSWORD:-}"
export OPENCODE_URL="${OPENCODE_URL:-http://127.0.0.1:4242}"
export TRAPOS_SERVER_HOST="${TRAPOS_SERVER_HOST:-0.0.0.0}"
export TRAPOS_SERVER_PORT="${TRAPOS_SERVER_PORT:-4444}"
exec npm run dev --prefix tools/trapos-server -- "$@"