Skip to content

Commit 3f5386d

Browse files
authored
Merge pull request #352 from abdegenius/feature/115-health-check-env-config
feat(backend): add health check endpoint and env configuration docs
2 parents 466b34d + 702e25e commit 3f5386d

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

backend/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,93 @@ done
116116

117117
---
118118

119+
## Health Check
120+
121+
### GET /health
122+
123+
Returns the live status of all backend dependencies. No authentication required.
124+
125+
```bash
126+
curl http://localhost:3001/health
127+
```
128+
129+
**Response — all healthy (HTTP 200):**
130+
131+
```json
132+
{
133+
"status": "ok",
134+
"indexer": "ok",
135+
"supabase": "ok",
136+
"timestamp": "2026-04-23T11:00:00.000Z"
137+
}
138+
```
139+
140+
**Response — dependency down (HTTP 503):**
141+
142+
```json
143+
{
144+
"status": "degraded",
145+
"indexer": "error",
146+
"supabase": "ok",
147+
"timestamp": "2026-04-23T11:00:00.000Z"
148+
}
149+
```
150+
151+
| Field | Values | Description |
152+
| ----------- | ------------------- | ------------------------------------------------ |
153+
| `status` | `ok` / `degraded` | Overall health — `degraded` if any check fails |
154+
| `indexer` | `ok` / `error` | Reachability of tikka-indexer `/health` |
155+
| `supabase` | `ok` / `error` | Reachability of Supabase REST endpoint |
156+
| `timestamp` | ISO 8601 string | Time the check was performed |
157+
158+
The endpoint returns **HTTP 503** when `status` is `degraded`, so orchestrators (Kubernetes, Railway, Fly.io) can detect unhealthy instances automatically.
159+
160+
---
161+
162+
## Environment Variables
163+
164+
Copy `.env.example` to `.env` and fill in the required values before starting the server.
165+
166+
```bash
167+
cp .env.example .env
168+
```
169+
170+
The app validates all variables at startup using Zod. Missing or invalid required vars cause an immediate startup failure with a clear error message listing every invalid field.
171+
172+
### Required
173+
174+
These must be set or the app will refuse to start:
175+
176+
| Variable | Description |
177+
| -------------------------- | ------------------------------------------------------------ |
178+
| `SUPABASE_URL` | Full URL of your Supabase project (e.g. `https://xyz.supabase.co`) |
179+
| `SUPABASE_SERVICE_ROLE_KEY`| Supabase service role key (not the anon key) |
180+
| `JWT_SECRET` | Secret for signing JWTs — **minimum 32 characters** |
181+
| `VITE_FRONTEND_URL` | Frontend origin allowed by CORS (e.g. `https://app.tikka.io`) |
182+
| `ADMIN_TOKEN` | Bearer token for `/admin/*` endpoints |
183+
184+
### Optional (with defaults)
185+
186+
| Variable | Default | Description |
187+
| -------------------------- | -------------------------- | ------------------------------------------------ |
188+
| `PORT` | `3001` | HTTP port the server listens on |
189+
| `INDEXER_URL` | `http://localhost:3002` | Base URL of the tikka-indexer internal API |
190+
| `INDEXER_TIMEOUT_MS` | `5000` | HTTP timeout for indexer requests (ms) |
191+
| `JWT_EXPIRES_IN` | `7d` | JWT expiry duration (e.g. `1h`, `7d`) |
192+
| `SIWS_DOMAIN` | `tikka.io` | Domain shown in the SIWS sign-in message |
193+
| `ADMIN_IP_ALLOWLIST` | `""` (allow all) | Comma-separated CIDRs/IPs for admin access |
194+
| `FCM_ENABLED` | `false` | Enable Firebase Cloud Messaging push notifications |
195+
| `FCM_SERVICE_ACCOUNT_JSON` || FCM service account JSON string (for CI/secrets) |
196+
| `FCM_SERVICE_ACCOUNT_PATH` || Path to FCM service account JSON file |
197+
| `THROTTLE_DEFAULT_LIMIT` | `100` | Max requests per window for public endpoints |
198+
| `THROTTLE_DEFAULT_TTL` | `60` | Rate-limit window size in seconds |
199+
| `THROTTLE_AUTH_LIMIT` | `10` | Max requests per window for `POST /auth/verify` |
200+
| `THROTTLE_AUTH_TTL` | `60` | Rate-limit window for auth tier (seconds) |
201+
| `THROTTLE_NONCE_LIMIT` | `30` | Max requests per window for `GET /auth/nonce` |
202+
| `THROTTLE_NONCE_TTL` | `60` | Rate-limit window for nonce tier (seconds) |
203+
204+
---
205+
119206
## Structure
120207

121208
- `src/api/rest/` - raffles, users, leaderboard, stats, search, notifications

0 commit comments

Comments
 (0)