https://github.com/cdfer/gtfs-realtime-cache-server
https://github.com/cdfer/gtfs-realtime-cache-server
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/cdfer/gtfs-realtime-cache-server
- Owner: CDFER
- License: mit
- Created: 2025-03-24T05:30:13.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-24T05:48:20.000Z (about 1 year ago)
- Last Synced: 2025-03-24T06:30:46.614Z (about 1 year ago)
- Language: TypeScript
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# GTFS Realtime Cache Server
A caching server for Auckland Transport's realtime GTFS data using Express and Bun.
## Features
- Fetches data every 20 seconds from AT API
- Gzip/Brotli compression
- CORS enabled
- Rate limiting protection
- Docker support
- Status monitoring endpoint
## 🚀 Quick Start
### Requirements
- Docker Desktop ([Download](https://www.docker.com/products/docker-desktop))
- Windows: Enable WSL2 for better performance
### Setup with Docker
1. Create `.env` file:
```env
API_KEY=your_api_key_here
PORT=3000
# Optional rate limiting (default: 20 requests/minute per IP)
# RATE_LIMIT_WINDOW_MS=60000
# RATE_LIMIT_MAX=20
```
2. Start container from PowerShell in project folder:
```powershell
docker compose up --build
```
3. Access:
-
-
## 💻 Local Development
1. Install Bun
2. Install dependencies:
```bash
bun install
```
3. Create `.env` file:
```env
API_KEY=your_api_key_here
```
4. Start server:
```bash
bun server.ts
```
## 🌐 Endpoints
| Endpoint | Description | Rate Limited |
|----------------|--------------------------------------|--------------|
| `GET /` | Basic server status | ✓ |
| `GET /api/data`| Cached GTFS data | ✓ |
| `GET /status` | Server metrics and uptime | ✓ |
## 🔧 Configuration
Environment variables:
- `API_KEY` (Required) - AT API subscription key
- `PORT` - Server port (default: 3000)
- `RATE_LIMIT_WINDOW_MS` - Rate limit window in ms (default: 60000)
- `RATE_LIMIT_MAX` - Max requests per IP per window (default: 20)
## ⚠️ Rate Limits
Default protection applied to all endpoints:
- 20 requests per minute per IP address
- Returns HTTP 429 status for exceeded limits
- Customizable via environment variables
## 📄 License
MIT License - See [LICENSE](LICENSE)