#!/usr/bin/env sh
set -eu

BASE_URL="${BASE_URL:-http://127.0.0.1:3010}"
HEALTH_URL="${BASE_URL%/}/api/health"

echo "Checking ${HEALTH_URL}"
response="$(curl -fsS "$HEALTH_URL")"
echo "$response"

case "$response" in
  *'"status":"ok"'*) exit 0 ;;
  *) echo "Healthcheck failed" >&2; exit 1 ;;
esac
