Configuration
info
For detailed security recommendations (HTTPS, etc.), see the Deployment page.
All configuration for the Base Worker is managed through the .env
file. The file src/config/index.ts
loads these variables and makes them available in your code.
Environment Variables
Below are the main environment variables used by the Base Worker.
Variable | Description | Default |
---|---|---|
AUTH_KEY | Authentication key required to access the Worker endpoints (except /health public info). | default-auth-key |
LB_AUTH_KEY | Key used to validate requests coming from the Load Balancer. Change only if you use it. | default-lb-auth-key |
PORT | HTTP port for the Worker API. | 3000 |
WEBSOCKET_PORT | Port for the WebSocket server (for real-time slot updates with the Load Balancer ; change only if you use it). | 3001 |
GROUP | The group this Worker belongs to (used for routing and contract versioning). | default |
CONTRACT | The contract version implemented by this Worker. | 1 |
SLOTS | Number of parallel tasks the Worker can handle. | 10 |
DEFAULT_TIMEOUT | Default timeout (ms) for task execution. | 30000 |
LOG_LEVEL | Log verbosity (info , warn , error , etc.). | info |
MAX_LOGS | Number of log lines to keep in memory (for /logs ). | 1000 |
WEBHOOK_TIMEOUT | Timeout (ms) for webhook calls. | 5000 |
WEBHOOK_MAX_RETRIES | Number of times to retry a failed webhook. | 3 |
WEBHOOK_RETRY_DELAY | Delay (ms) between webhook retries. | 1000 |
WEBHOOK_HEADERS | JSON object of headers to send with webhook requests. | {} |
OPENAPI_ENABLED | Enable OpenAPI documentation endpoints (/docs and /openapi ). | true |
Usage
- All configuration is loaded at startup and available via the
config
object insrc/config/index.ts
. - These variables control authentication, routing, logging, slot management, and advanced features.
Example .env
AUTH_KEY=default-auth-key
LB_AUTH_KEY=default-lb-auth-key
PORT=3000
WEBSOCKET_PORT=3001
GROUP=default
CONTRACT=1
SLOTS=10
DEFAULT_TIMEOUT=30000
LOG_LEVEL=info
MAX_LOGS=1000
WEBHOOK_TIMEOUT=5000
WEBHOOK_MAX_RETRIES=3
WEBHOOK_RETRY_DELAY=1000
WEBHOOK_HEADERS={}
OPENAPI_ENABLED=true