Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/user-api-dev-stack-lane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: add a local dev-stack lane for the User API (`scripts/dev.sh`) + `pnpm user-api` root alias. Optional, mirroring Address Enrichment — runs via `railway run` when the service is available and exports `USER_API_URL` for the dashboard `/api/user` proxy; skipped otherwise so existing flows are unaffected.
1 change: 1 addition & 0 deletions .claude/skills/local-dev-stack/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ the first.
| Dashboard | 3000 | http://localhost:3000 | always |
| Address Enrichment | 3001 | http://localhost:3001 | optional, skipped if no Railway svc |
| Relayer (ENS) | 3002 | http://localhost:3002 | ENS only |
| User API | 4003 | http://localhost:4003 | optional, skipped if no Railway svc |

Client SDK codegen runs in watch mode (no port) and regenerates on API/gateful changes.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"indexer": "dotenv -- turbo run --filter=@anticapture/indexer",
"gateful": "dotenv -- turbo run --filter=@anticapture/gateful",
"authful": "dotenv -- turbo run --filter=@anticapture/authful",
"user-api": "dotenv -- turbo run --filter=@anticapture/user-api",
"api": "dotenv -- turbo run --filter=@anticapture/api",
"codegen": "dotenv -- node scripts/wait-for-gateful.mjs && dotenv -- turbo run codegen",
"client": "turbo run --filter=@anticapture/client",
Expand Down
25 changes: 24 additions & 1 deletion scripts/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ PORT_GATEFUL=4001
PORT_DASHBOARD=3000
PORT_ADDRESS_ENRICHMENT=3001
PORT_RELAYER=3002
PORTS=("$PORT_INDEXER" "$PORT_API" "$PORT_GATEFUL" "$PORT_DASHBOARD" "$PORT_ADDRESS_ENRICHMENT" "$PORT_RELAYER")
PORT_USER_API=4003
PORTS=("$PORT_INDEXER" "$PORT_API" "$PORT_GATEFUL" "$PORT_DASHBOARD" "$PORT_ADDRESS_ENRICHMENT" "$PORT_RELAYER" "$PORT_USER_API")

# DAO name → short ID mapping (used to run the API)
dao_id_for() {
Expand Down Expand Up @@ -58,6 +59,7 @@ C_CODEGEN="\033[33m" # yellow
C_DASHBOARD="\033[32m" # green
C_ADDRESS_ENRICHMENT="\033[96m" # bright cyan
C_RELAYER="\033[93m" # bright yellow
C_USER_API="\033[95m" # bright magenta
C_SCRIPT="\033[90m" # gray
C_RESET="\033[0m"

Expand Down Expand Up @@ -247,6 +249,22 @@ else
log "Skipping optional Address Enrichment (Railway CLI/service unavailable)"
fi

# 4. User API (optional; identity + drafts + API keys). Needs its own Postgres,
# supplied by the Railway dev env — so it runs like enrichment: via `railway
# run`, skipped when the service/CLI isn't available. When up, the dashboard's
# /api/user proxy targets it; when skipped, auth/drafts UIs are simply inert.
USER_API_AVAILABLE=false
if railway_service_available "user-api"; then
log "Starting optional User API..."
run_with_prefix "$C_USER_API" "👤 user-api" "" "" railway run -e dev -s user-api pnpm user-api dev &
if wait_for_optional_port "$PORT_USER_API" "User API"; then
USER_API_AVAILABLE=true
export USER_API_URL="http://localhost:${PORT_USER_API}"
Comment on lines +260 to +262

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Export USER_API_URL before waiting on readiness

When the User API takes more than the optional 20s to bind (for example a cold turbo dev build or a slow Railway Postgres connection), this branch leaves the background process running but does not export USER_API_URL before starting the dashboard. The Next proxy then inherits no USER_API_URL and /api/user keeps throwing “USER_API_URL is not configured” even if the service comes up seconds later; set the URL once the lane is started, or stop the process when the timeout path is chosen.

Useful? React with 👍 / 👎.

fi
else
log "Skipping optional User API (Railway CLI/service unavailable)"
fi

# Watchdog: when API recovers after being down, touch the sentinel file so tsx reloads the gateful
if [ "$RUN_API" = true ]; then
(
Expand Down Expand Up @@ -295,6 +313,11 @@ if [ "$ADDRESS_ENRICHMENT_AVAILABLE" = true ]; then
else
printf " ${C_ADDRESS_ENRICHMENT}💰 Enrichment${C_RESET} skipped (optional)\n"
fi
if [ "$USER_API_AVAILABLE" = true ]; then
printf " ${C_USER_API}👤 User API${C_RESET} http://localhost:${PORT_USER_API}\n"
else
printf " ${C_USER_API}👤 User API${C_RESET} skipped (optional)\n"
fi
printf " ${C_GATEFUL}🚪 Gateful${C_RESET} http://localhost:${PORT_GATEFUL}\n"
printf " ${C_RELAYER}📡 Relayer${C_RESET} http://localhost:${PORT_RELAYER}\n"
printf " ${C_CODEGEN}🤝 REST Client${C_RESET} codegen + build watch\n"
Expand Down
Loading