because I got bored of customising my CV for every job
1#!/bin/sh
2
3# Server health check script
4# Checks if the GraphQL server is responding with a proper health query
5
6# Default values
7SERVER_PORT=${SERVER_PORT:-3000}
8HEALTH_QUERY='{"query":"query HealthCheck { __typename }"}'
9
10# Check if the GraphQL server is responding
11if ! curl -f -s \
12 --request POST \
13 --header "Content-Type: application/json" \
14 --data "$HEALTH_QUERY" \
15 "http://localhost:${SERVER_PORT}/graphql" > /dev/null; then
16 echo "GraphQL server not responding on port ${SERVER_PORT}"
17 exit 1
18fi
19
20# Check if the response contains expected GraphQL structure
21RESPONSE=$(curl -s \
22 --request POST \
23 --header "Content-Type: application/json" \
24 --data "$HEALTH_QUERY" \
25 "http://localhost:${SERVER_PORT}/graphql")
26
27if ! echo "$RESPONSE" | grep -q '"data"'; then
28 echo "GraphQL server not returning valid response"
29 echo "Response: $RESPONSE"
30 exit 1
31fi
32
33echo "Server health check passed"
34exit 0