Map distribution (/maps/v1)
The site serves the signed region packages of ORIX Maps the same way it serves the model library of ORIX Astra
(/astra/models/v1): plain files, no account, no API key, no page. The contract is docs/CATALOG_API.md of the ORIX
Maps repository (section 2, "Server requirements"); the route is src/app/maps/v1/[...path]/route.ts, the tests are
tests/maps.test.ts.
The public page /maps (/fr/maps, src/app/[locale]/maps/page.tsx) lists the published regions for visitors. It reads
catalog.json and regions/<id>.json from the same directory through src/lib/maps.ts (tests:
tests/maps-library.test.ts), offers no link to a package, and shows an empty state when no catalogue is published.
Resources
GET / HEAD |
File under the distribution root | Content-Type |
Cache-Control |
|---|---|---|---|
/maps/v1/catalog.json |
catalog.json |
application/json |
public, max-age=300 |
/maps/v1/regions/<id>.json |
regions/<id>.json |
application/json |
public, max-age=300 |
/maps/v1/regions/<id>/versions.json |
regions/<id>/versions.json |
application/json |
public, max-age=300 |
/maps/v1/files/<id>/<dataVersion>/<id>-<dataVersion>.orixmap |
same path | application/vnd.orix.map |
public, max-age=31536000, immutable, no-transform |
<id> is [a-z0-9-]{1,64}; <dataVersion> is a dotted decimal version (up to eight groups of digits). Every other
path answers 404, including pins.json (publisher state) and any other file placed in the directory.
Distribution directory
ORIX_MAPS_DIR (default ~/apps-data/orix-maps) + /v1, outside the deployment and outside git. It is written by
orix-package publish / orix-package catalog (ORIX Maps repository), which replace each file by a rename and write
catalog.json last; the route only reads.
~/apps-data/orix-maps/v1/catalog.json
~/apps-data/orix-maps/v1/regions/ca-qc-montreal.json
~/apps-data/orix-maps/v1/regions/ca-qc-montreal/versions.json
~/apps-data/orix-maps/v1/files/ca-qc-montreal/2026.11.24/ca-qc-montreal-2026.11.24.orixmap
~/apps-data/orix-maps/v1/pins.json (never served)An empty or missing directory is a valid state: everything answers 404. Publishing needs no restart: documents are read
again when their modification time or size changes. Never overwrite a published package (its URL is cached as
immutable); new data is a new dataVersion. Packages signed with a development key must not be placed here.
Behaviour
- Listing rule. A package is served only when the current
catalog.json(regions[].latest) or the region'sversions.json(versions[]) lists it with that exactpath, adownloadSizeand a 64-digit lowercasesha256, and the size on disk equalsdownloadSize. Otherwise 404. Removing a version from both documents withdraws it. - ETag. Always strong:
"<sha256 hex>". For a package it is the listedsha256(packages are never hashed by the server: the bytes are only checked by size, the application verifies digest and signature). For a JSON document it is the SHA-256 of the file, computed once per (mtime, size). If-None-Match→304(list of tags,*, weak comparison), evaluated beforeRange.Range(packages,GETonly):bytes=a-b,bytes=a-and the suffix formbytes=-n→206withContent-RangeandContent-Length; a last byte past the end is clamped. A range starting at or after the end, orbytes=-0→416withContent-Range: bytes */<size>. A header that asks for several ranges, uses another unit or is malformed is ignored and the whole file is sent with200(RFC 9110 §14.2 allows a server to ignoreRange).HEADignoresRangeand reports the full length.If-Range: the range is honoured only when the value is exactly the current strong ETag. Any other value (another tag, a weak tag, a date) →200with the whole file, even when the range itself would be unsatisfiable.- Headers on every answer:
X-Content-Type-Options: nosniff,X-Robots-Tag: noindex,Access-Control-Allow-Origin: *;Accept-Ranges: byteson packages. NeverSet-Cookie, neverContent-Encoding(the site does not compress;no-transformasks the gateway not to compress a package either). Content-Length: set by the route, not on the wire. The handler setsContent-Lengthon every 200 and 206 (the tests check it), but Next.js 16.4 removesContent-Lengthfrom every route-handler response (FORBIDDEN_HEADERSinnext/dist/server/send-response.js) and sends the body with chunked transfer encoding; aHEADanswer carries no length either. The same holds for/astra/models/v1. Clients must take the size from the catalog (downloadSize) or fromContent-Range(bytes a-b/<total>, which is delivered); a truncated transfer is still detected by the HTTP framing. Sending the header would need a response written outside the App Router (a Pages API route or the gateway).- Safety. The URL must match one of the four shapes before the file system is touched; the resolved path
(
realpath) must stay under the resolved distribution root, so neither..nor a symbolic link can lead outside. A JSON document larger than 8 MiB (the client's own limit) is not served. - Rate limit. 300 requests per 60 seconds and per client address (scope
orix-mapsoflib/security/ratelimit), then429withRetry-After: <seconds until the window ends>. A download costs one request per attempt or resume. - Errors. An unexpected failure answers a bare
500and logs nothing.
Requests without a file extension that match none of the shapes (/maps/v1/regions/x) never reach the route: the locale
proxy rewrites them to the site's own 404 page (status 404, HTML), like any unknown page.
What is recorded about a download
- The route: nothing. No log line, no counter, no database row, no file. (The anonymous download counters of
/downloaddo not apply here.) - The Next.js process (
orix-webunder PM2, logs in~/.pm2/logs/orix-web-{out,error}.log):next startwrites no access log. The output log holds start-up lines only; the error log holds stack traces of unexpected server errors, without address or headers. - In memory only: the rate limiter keeps, per client address, a request count and the end of the current
60-second window (
orix-maps:<address>). It is never written to disk, is gone at every restart oforix-web, and expired entries are dropped when the table is pruned. - The gateway (Caddy on the public server, in front of this node) terminates TLS and sees the address, the time, the URL and the size of every request. Whether and how long it logs them is its own configuration, outside this repository.
Operations
mkdir -p ~/apps-data/orix-maps/v1 # once per node (the directory does not follow `mld move`)
curl -sI localhost:8830/maps/v1/catalog.json # 404 until a catalog is published, 200 afterwards
pnpm exec vitest run tests/maps.test.ts