Tiny server to handle connection with activity trackers such as Strava, Garmin or Suunto
Click a diagram to open its interactive version (zoom, search, details, links to the source code). All the diagrams of camptocamp.org: https://c2corg.github.io/v6_api/.
Requires Node.js 26 (see engines).
npm install- Configure Strava, Suunto, etc. applications. You might use
ngroktool to make your localhost application reachable from the internet. - Set required environment variables in
.envfile. - Launch the app:
npm run start
DB_ENABLE_SSL=true encrypts the connection to PostgreSQL. By default the server certificate is not checked.
To check it (chain and host name, DB_HOST must be a name of the certificate):
DB_SSL_REJECT_UNAUTHORIZED=true;DB_SSL_CA_FILE=/path/to/ca.crtwhen the server certificate comes from a private authority (without it, the system authorities are used).
You can debug server and tests within Visual Studio Code using the predefined configurations in launch.json.
GET /health: liveness, the process answers (version, uptime, enabled trackers). Used by the Docker health check.GET /health/ready: readiness, 200 when the database answers within 2 s, 503 otherwise.
Every route validates its input (URL parameters, query, headers, body) with validate(...) and zod schemas
(src/server/*/*.validators.ts); routes that read nothing use validate(noInput). The local ESLint rule
local/require-route-validation (eslint-rules/) enforces it.
Tests run with Vitest, in three projects:
npm run test:unit: unit tests, no external service needed (npm run test:watchto rerun them on change);npm run test:psql: repository tests, against the PostgreSQL ofdocker compose -f docker-compose.psql.yml up -d. The schema of thepostgresdatabase is recreated before the run;npm run test:s3: storage tests, against the in-memory S3 server (Scality CloudServer) ofdocker compose -f docker-compose.s3.yml up -d s3. The tests create the bucket.
npm test runs the unit and psql tests.
To create a release,
- On
mainbranch, run commandnpm version (major|minor|patch)to updatepackage(-lock).jsonversions and create a tag. - Push tag
- CI/CD process will automatically create the release from tag and generate release notes.
In order to produce nice release notes:
- Assign labels to pull requests
- See release.yml to define categories.