#!/usr/bin/env bash
# Run Postman/Newman API regression against local server
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT/backend"
if ! curl -sf http://localhost:3000/api/v1/health >/dev/null 2>&1; then
  echo "Start backend first: npm run dev"
  exit 1
fi
npx --yes newman run "$ROOT/docs/postman/leaves-api.postman_collection.json" \
  -e "$ROOT/docs/postman/leaves-api.postman_environment.json" \
  --reporters cli
