Skip to content

6.4.0

Latest

Choose a tag to compare

@20syldev 20syldev released this 17 Nov 00:39
6.4.0
731588e

Feature release for moxon API: the server now ships as a public Docker image, and the manifest grows from one endpoint to 41, because most of the HTTP routes are now declared as contracts. Nothing changes in what the API answers: v4, v5 and v6 behave exactly as in 6.3.0, apart from the stricter text of a badge.

Endpoint contracts and manifest

  • 41 endpoints declared as contracts — the route, the check of the parameters and the description used by the documentation now come from one declaration, so they cannot drift apart. They are address, agent, algorithms, asymmetric, base, case, color, convert, credit, cron, csv, dice, diff, domain, encode, evaluate, geo, hash, headers, hyperplanning, ip, jwt, levenshtein, matrix, otp, palette, password, personal, pow (the challenge), read, regex, semver, statistics, symmetric, text, time, token, url, username, uuid and validate.
  • Same answers, in every version — each migrated endpoint keeps its statuses, its messages, the order of its checks and the way it reads empty values, repeated query keys and wrong JSON types, in v4, v5 and v6. The answers of more than 5,000 requests were recorded before the change and are replayed by the tests, and every migration was also compared request by request, on about 120,000 more, against the code of 6.3.0.
  • A richer manifest — @moxon/api/manifest now lists 42 entries (levenshtein is a GET until v5 and a POST from v6). Each entry has its name, method, path, category, the first (since) and last (until) version that serve it, its params with their type, fixed options and default, and a request example. A parameter is marked required only when a request without it is refused before the endpoint runs.
  • Still experimental — the endpoints that answer an image, keep a state (chat, tic-tac-toe, the verification of captcha and proof of work) or describe the API itself are not declared yet, and the shape of the manifest may still change in a minor release.

Docker

  • A public image — ghcr.io/moxondev/api, for linux/amd64 and linux/arm64. Run it with docker run -d -p 3000:3000 ghcr.io/moxondev/api:latest: it listens on port 3000 and reads the same environment variables as the Node server (PORT, CHALLENGE_SECRET, TRUSTED_PROXIES, DOCS_URL, the rate limits and the rest), also from a file with --env-file.
  • Tags — 6.4.0, 6.4 and 6 follow the releases, latest is the most recent stable one and edge is the tip of the default branch, ahead of any release.
  • Made for a locked-down host — the image runs as the unprivileged node user and writes nothing to disk, so it also starts with --read-only --tmpfs /tmp. It reports itself healthy once GET / answers, and it stops at once on SIGTERM instead of waiting to be killed.
  • Captchas and badges work out of the box — the fonts and their cache are installed in the image, and canvas comes with its prebuilt binary, so nothing is compiled when the image is built.
  • Checked before every publication — the workflow runs the checks and the tests, starts the freshly built image with a read-only filesystem and queries it (/, a badge, a captcha, its health) before pushing anything. The arm64 image is started too.
  • Behind a proxy — set TRUSTED_PROXIES, otherwise the server sees the address of the proxy or of the Docker network instead of the caller's, and rate limits count the wrong clients. The README has a new Docker section with the commands.

Badge

  • Invisible characters are refused — the text of GET /v6/badge (label and message) can no longer hold a soft hyphen, a word joiner, a bidirectional mark, a Hangul or Braille filler, a tag character, a lone surrogate or another invisible character. A text made only of spaces, combining marks or variation selectors is refused too. All of them answer the same 400 as the control characters before them: Label cannot contain control or invisible characters.
  • What still works — emoji with their variation selector (❤️), accents, no-break spaces and the ideographic space around a visible text are accepted as before.

Package

  • canvas 3.2.3 — the new release carries a prebuilt binary for linux-arm64, which is what makes the arm64 image possible. Nothing changes for the library.
  • Lint toolchain — a vulnerable minimatch pulled in by the development dependencies is replaced by a patched release. It only concerned the development tools: it was never installed with @moxon/api.
  • Description — the package now announces 50+ endpoints, in the npm description and in the README.
  • Steadier tests — the tests that measured elapsed time (cron, regular expressions, calendars, key generation) no longer depend on the speed of the machine: the clock is frozen, the deadlines are proven with a fake one, and the remaining bounds only guard against a hang.