Deploy
This section is for whoever hosts the Towers API. If you only call it, you do not need it.
The API is a single Node.js service with a SQLite file beside it. It needs Node.js 24 or Docker, and very little else.
With Docker
Section titled “With Docker”-
Get the code onto the server and go to the
backendfolder. -
Start it
Terminal window docker compose up -d --buildThe API listens on
127.0.0.1:7552, reachable only from the server itself. Its data lives in a Docker volume namedtowers-data, so it survives restarts and rebuilds. -
Put HTTPS in front of it
Use a reverse proxy to add TLS and to publish only the keyed Engine endpoints
/towers,/placements,/recoveriesand/comparisons. With Caddy, which fetches certificates by itself. Replacetowers-api.example.invalidwith your API hostname in the examples below.Caddyfile towers-api.example.invalid {@engine path /api/v1/towers /api/v1/placements /api/v1/recoveries /api/v1/comparisonshandle @engine {reverse_proxy 127.0.0.1:7552}handle {respond 404}} -
Issue a key and try it
Terminal window docker compose exec api node dist/cli/keys create "Smoke test"Terminal window curl https://towers-api.example.invalid/api/v1/towers \-H "Authorization: Bearer twr_..." \-H "Content-Type: application/json" \-d '{"program":{"contracts":[{"contractRef":"C-1","currency":"USD","layers":[{"layerName":"First excess","layerType":"XOL","lowerLimit":100,"upperLimit":200,"isUnlimited":false,"order":100}]}],"risks":[{"riskId":"R-1","contractRefs":["C-1"]}]}}'A
200with arisksarray means it is working. Revoke the test key afterwards.
Without Docker
Section titled “Without Docker”cd backendnpm cinpm run buildSEED_DEMO=false node dist/mainKeep it running with your process manager of choice, such as systemd.
Settings
Section titled “Settings”All are environment variables, and all are optional.
| Variable | Default | |
|---|---|---|
PORT |
7552 |
The port to listen on. |
DATABASE_PATH |
data/programs.db (/data/programs.db in Docker) |
The SQLite file holding API keys and stored programs. |
SEED_DEMO |
on | Set to false to disable demo seeding, including after legacy rows are cleared. The Docker setup does this. |
FRONTEND_URL |
http://localhost:5173 |
The one browser origin allowed to call the API, for the bundled programs app. |
Back up
Section titled “Back up”Everything worth keeping is the one SQLite file: the fingerprints of the keys you have issued, and any stored programs. Copy it on a schedule. If it is lost, every client needs a new key.
Update
Section titled “Update”git pulldocker compose up -d --buildAPI keys are preserved. Stored requests in the old format without program.contracts are cleared on startup; current-format imports are kept. Missing demos are re-seeded after a legacy clear unless SEED_DEMO=false.