#!/bin/bash

# Start the server in background
echo "Starting ticket server..."
pnpm run server:dev &
SERVER_PID=$!

# Wait for server to start
sleep 2

# Test endpoints
echo -e "\n--- Testing Health Endpoint ---"
curl -s http://localhost:4932/health | jq

echo -e "\n--- Testing Ticket Existence ---"
curl -s http://localhost:4932/api/ticket/exists | jq

echo -e "\n--- Testing Ticket Content ---"
curl -s http://localhost:4932/api/ticket | jq

# Kill the server
echo -e "\n--- Stopping server ---"
kill $SERVER_PID