#!/nix/store/ypgcdmzzlgnrmdcsq72c3dxz651jg9zc-bash-5.3p3/bin/bash # Start the server in the background ./markdown-editor --data-dir ./test/data --port 8082 --host 127.0.0.1 & SERVER_PID=$! # Give the server time to start sleep 2 # Test the /api/files endpoint echo "Testing GET /api/files..." response=$(curl -s -i http://127.0.0.1:8082/api/files) echo "$response" echo "" # Extract just the body (skip headers) body=$(echo "$response" | awk 'NR>1 && $0 !~ /^[A-Za-z]/ {print; next} /^[A-Za-z]/ {exit}') echo "Body: '$body'" echo "" # Test if it's valid JSON echo "Checking if response is valid JSON..." if echo "$body" | node -e "console.log(JSON.parse(require('fs').readFileSync(0, 'utf8')))" > /dev/null 2>&1; then echo "✓ Response is valid JSON" echo "$body" | node -e "console.log(JSON.parse(require('fs').readFileSync(0, 'utf8')))" else echo "✗ Response is NOT valid JSON" echo "Response was: '$body'" fi # Kill the server kill $SERVER_PID 2>/dev/null wait $SERVER_PID 2>/dev/null echo "Test completed"