This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run dev- Start development server with hot reload using tsx watchnpm run build- Compile TypeScript to JavaScript in dist/ directorynpm start- Run the built application from dist/npm test- Run all tests using Vitestnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coverage reportnpm run lint- Format and lint code using Biome (auto-fixes issues)npm run lint:check- Check linting without auto-fixingnpm run typecheck- Run TypeScript type checking without compilation
- Express Router Service: Main HTTP server handling compilation and cmake requests for Compiler Explorer
- HTTP Forwarder (
src/services/http-forwarder.ts): Direct HTTP forwarding to target URLs with proper header handling - WebSocket Manager (
src/services/websocket-manager.ts): Robust WebSocket client with automatic reconnection, subscription management, and ping/pong keepalive - AWS Clients (
src/services/aws-clients.ts): Pre-configured AWS SDK v3 clients for DynamoDB, S3, SQS, SSM, and STS
POST /api/compiler/:compilerid/compile- Handles compilation requests for specific compilersPOST /api/compiler/:compilerid/cmake- Handles CMake build requestsPOST /:env/api/compiler/:compilerid/compile- Environment-prefixed compilation requests (beta, staging)POST /:env/api/compiler/:compilerid/cmake- Environment-prefixed CMake requestsGET /healthcheck- Health status including WebSocket connection state
The service maintains a persistent WebSocket connection to wss://events.compiler-explorer.com/beta (configurable) for real-time communication. The WebSocketManager provides:
- Automatic reconnection with exponential backoff
- Topic-based subscription/unsubscription
- Message serialization/deserialization
- Connection health monitoring via ping/pong
- Port: Environment variable
PORTor CLI flag--port(default: 3000) - WebSocket URL: Environment variable
WEBSOCKET_URLor CLI flag--websocket - AWS Region: Environment variable
AWS_REGION(default: us-east-1)
- TypeScript: ES2022 target with NodeNext module resolution
- Biome: Used for both linting and formatting (4-space indentation, 120 char line width)
- Vitest: Test runner with coverage support and mocking
- ESM: Project uses ES modules with .js extensions in imports
- 4-space indentation
- Single quotes for strings
- Trailing commas
- 120 character line width
- Strict TypeScript configuration with unused parameter/local detection
The service supports two routing methods:
- Requests are sent to SQS queues for processing
- Results are returned via WebSocket connections
- Supports automatic failover and load balancing
- Used for most compilation requests
- Direct HTTP forwarding to specific target URLs
- Configured via DynamoDB routing table
- Used for specialized compilers (e.g., GPU compilers)
- Handles HTTP header normalization to prevent protocol violations
- HTTP responses automatically remove conflicting headers (e.g.,
transfer-encodingwhen settingcontent-length) - Large responses (>1MB) are flagged with warnings due to ALB limits
- CORS headers are automatically added to all responses
The codebase is a TypeScript replacement for an AWS Lambda function, designed to handle Compiler Explorer routing requests with both WebSocket-based real-time communication and direct HTTP forwarding.
- Always lint and check the code when you have finished code changes
- Use debug-level logging for detailed troubleshooting information
- Keep info-level logging for essential operational messages
- Prefer unit tests for pure functions over integration tests where possible