#!/usr/bin/env bash
# Run API (server) and Vite (app) together. Requires: npm install at repo root, server/, and app/.
# FRONTEND_URL in server/.env should match the URL you open (e.g. https://new.breathenbeing.com).
# If PM2 already uses 3051: pm2 stop yoga_assessment
# Free ports then start: npm run dev:fresh
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
if [[ "${1:-}" == "--install" ]]; then
  npm install
  (cd "$ROOT/server" && npm install)
  (cd "$ROOT/app" && npm install)
fi
exec npm run dev
