Repository navigation
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,uuidandvalidate. - 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,v5andv6. 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/manifestnow lists 42 entries (levenshteinis aGETuntilv5and aPOSTfromv6). Each entry has itsname,method,path,category, the first (since) and last (until) version that serve it, itsparamswith theirtype, fixedoptionsanddefault, and a requestexample. A parameter is markedrequiredonly 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, forlinux/amd64andlinux/arm64. Run it withdocker run -d -p 3000:3000 ghcr.io/moxondev/api:latest: it listens on port3000and 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.4and6follow the releases,latestis the most recent stable one andedgeis the tip of the default branch, ahead of any release. - Made for a locked-down host — the image runs as the unprivileged
nodeuser and writes nothing to disk, so it also starts with--read-only --tmpfs /tmp. It reports itselfhealthyonceGET /answers, and it stops at once onSIGTERMinstead of waiting to be killed. - Captchas and badges work out of the box — the fonts and their cache are installed in the image, and
canvascomes 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. Thearm64image 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(labelandmessage) 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 same400as 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
canvas3.2.3 — the new release carries a prebuilt binary forlinux-arm64, which is what makes thearm64image possible. Nothing changes for the library.- Lint toolchain — a vulnerable
minimatchpulled 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.