Configuration
Everything is set by environment variables, usually in .env at the repository root. .env.example lists them with their defaults.
API
| Variable | Default | What it does |
|---|---|---|
NODE_ENV | development | production ignores the X-User header. See Users and sign-in |
HOST, PORT | 127.0.0.1, 3333 | Where the API listens. Keep it on loopback behind the proxy |
CORS_ORIGIN | http://localhost:3000 | Browser origins allowed to call the API, comma separated. Not needed when the proxy serves both under one address |
PUBLIC_API_URL | http://127.0.0.1:3333/api/v1 | Where ClassCAD engines reach the API to fetch the parts of an assembly |
DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME | localhost, 5002, pdm, pdm, pdm | The Postgres database |
STORAGE_PROVIDER | fs | Where files go. Only fs for now |
STORAGE_DIR | ./storage | The file store, relative to where the API runs |
DEV_USER | local-developer | Who a request is when it says nothing |
ADMIN_USERS | Logins with administrator rights, comma separated | |
LEASE_TTL_MINUTES | 30 | How long a reservation lasts without being renewed |
JOB_HEARTBEAT_TIMEOUT_S | 120 | A running job whose worker is quiet this long goes back to the queue |
JOB_MAX_ATTEMPTS | 3 | How often a job is tried |
JOB_REAPER_INTERVAL_S | 30 | How often the API looks for such jobs |
CODE_ALLOW_LOCAL_REPOS | false | Lets code documents point at git repositories on the worker's disk. Development only |
Job workers
| Variable | Default | What it does |
|---|---|---|
PDM_API_URL | http://127.0.0.1:3333/api/v1 | The API |
CC_URL | http://127.0.0.1:9094/api | ClassCAD. Point it at the scheduler: http://127.0.0.1:9091/api |
WORKER_ID | <host>:<pid> | The worker's name in jobs and logs |
WORKER_USER | classcad-worker | Who the worker is towards the API |
CLASSCAD_RENDERER_DIR | The ClassCAD renderer, for pictures. Without it, no pictures | |
RUN_TIMEOUT_S | 300 | A generator run that takes longer is stopped |
WORKER_ENVIRONMENT | base | Which jobs this worker takes, by the classes its ClassCAD has loaded |
GENERATOR_SDK_DIR | packages/generator-sdk | The generator SDK bundled into every run |
POLL_INTERVAL_MS, HEARTBEAT_MS | 2000, 10000 | How often the worker asks for work, and reports on it |
Use 127.0.0.1, not localhost, in ClassCAD addresses. ClassCAD listens on IPv4 only, and Node tries ::1 first for localhost.
Web app, at build time
| Variable | Default | What it does |
|---|---|---|
VITE_API_URL | /api/v1 | Where the browser finds the API |
EDITOR_RUNTIME | wasm | Where ClassCAD runs for the editor: wasm in the browser, drogon on the server |
CLASSCAD_WASM_KEY | The WebAssembly key, for wasm | |
CLASSCAD_WASM_URL | ClassCAD's CDN | Where the browser loads ClassCAD's WebAssembly from, if you host it yourself |
EDITOR_CC_URL | ws://127.0.0.1:9094 | The WebSocket for drogon: the scheduler, through your proxy |
These end up in the built files. Change them, build again.