-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdemo.sh
More file actions
65 lines (54 loc) · 1.69 KB
/
demo.sh
File metadata and controls
65 lines (54 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Weather & Stock API Demo Script
# This script demonstrates the API endpoints with real examples
BASE_URL="http://localhost:3000"
echo "🌤️ Weather & Stock API Demo"
echo "=================================="
echo ""
# Function to make API calls with nice formatting
api_call() {
local url="$1"
local description="$2"
echo "📡 $description"
echo " GET $url"
echo " Response:"
echo " --------"
curl -s "$url" | jq '.' || echo " (Failed to connect - is the server running?)"
echo ""
echo ""
}
# Check if server is running
echo "🔍 Checking if server is running..."
if ! curl -s "$BASE_URL/health" > /dev/null; then
echo "❌ Server is not running on $BASE_URL"
echo " Please start the server first:"
echo " ./bin/weather-stock-api"
echo ""
exit 1
fi
echo "✅ Server is running!"
echo ""
# Demo API endpoints
echo "🎯 API Demonstration"
echo "====================="
echo ""
# Health check
api_call "$BASE_URL/health" "Health Check"
# API info
api_call "$BASE_URL/" "API Information"
# Weather examples
api_call "$BASE_URL/weather?city=Stuttgart" "Weather for Stuttgart"
api_call "$BASE_URL/weather?city=Berlin" "Weather for Berlin"
api_call "$BASE_URL/weather/summary?city=New York" "Weather Summary for New York"
# Stock examples
api_call "$BASE_URL/stock/datadog" "Datadog Stock Price"
api_call "$BASE_URL/stock?symbol=AAPL" "Apple Stock Price"
api_call "$BASE_URL/stock/summary?symbol=DDOG" "Datadog Stock Summary"
echo "🎉 Demo completed!"
echo ""
echo "💡 Try these URLs in your browser:"
echo " $BASE_URL/"
echo " $BASE_URL/health"
echo " $BASE_URL/weather?city=Stuttgart"
echo " $BASE_URL/stock/datadog"
echo ""