REST API service voor externe toegang tot het datalake (MinIO) en student databases (PostgreSQL).
# Install dependencies
npm install
# Copy environment file
cp .env.example .env
# Generate API key
openssl rand -hex 32
# Add API key to .env
# API_KEYS=your-generated-key-here
# Start development server
npm run dev
# Build and start
docker compose up -d --build
# View logs
docker compose logs -f platform-api
Zie .env.example voor alle beschikbare environment variables.
Belangrijk:
API_KEYS: Comma-separated list van API keysDATABASE_URL: PostgreSQL connection stringMINIO_ENDPOINT: MinIO endpoint (gebruik platform-minio in Docker)# Generate a secure API key
openssl rand -hex 32
Voeg de gegenereerde key toe aan API_KEYS in je .env file:
API_KEYS=key1,key2,key3
Zie docs/external-access/API_ACCESS.md voor volledige API documentatie.
GET /api/students - List studentsGET /api/students/:id - Get student by IDGET /api/lessons - List lessonsGET /api/appointments - List appointmentsGET /api/datalake/students - List student foldersGET /api/datalake/students/:name/files - List files for studentGET /api/datalake/files/:path - Get file metadataGET /api/datalake/files/:path/download - Get download URLGET /health - Health check (no auth required)Alle API endpoints (behalve /health) vereisen een API key in de header:
X-API-Key: your-api-key-here
Default: 100 requests per minuut per API key.
Configureer via environment variables:
RATE_LIMIT_WINDOW_MS: Time window in milliseconds (default: 60000)RATE_LIMIT_MAX_REQUESTS: Max requests per window (default: 100)npm run dev # Start development server with hot reload
npm run build # Build TypeScript
npm run start # Start production server
npm run type-check # Type check without building
npm run lint # Lint code
src/
├── index.ts # Main server file
├── routes/ # API routes
│ ├── students.ts
│ ├── lessons.ts
│ ├── appointments.ts
│ └── datalake.ts
├── middleware/ # Express middleware
│ ├── auth.ts # API key authentication
│ ├── rateLimit.ts # Rate limiting
│ ├── logger.ts # Request logging
│ └── errorHandler.ts # Error handling
└── services/ # Business logic (future)
De service gebruikt het data-network Docker network om te verbinden met:
platform-postgres (PostgreSQL)platform-minio (MinIO)Zorg dat deze services draaien en op hetzelfde netwerk zitten.
# Check if PostgreSQL is running
docker ps | grep platform-postgres
# Test connection
docker exec -it platform-postgres psql -U postgres -d platform
# Check if MinIO is running
docker ps | grep platform-minio
# Test connection
curl http://localhost:9005/minio/health/live
.envX-API-Key correct is gespeldcurl -H "X-API-Key: your-key" http://localhost:8082/api/students⚠️ Belangrijk voor productie:
Private - Internal use only