Skip to content

feat(mock): scaffold the docs mock server #588

Open

Description

@uniqueg

Why

The docs previews need a backend we control (#419). This issue sets up the
empty service so that the API stubs (sibling issues) can be added in small
PRs.

What to do

  • Add a workspace apps/mock-server (TypeScript, Node >= 22, the repo's
    engine range), using Node's built-in http server and as few runtime
    dependencies as possible.
  • Router with a 404 JSON default, CORS (any origin, GET, POST, PUT, DELETE, OPTIONS, preflight answers), GET /healthz, port from PORT
    (default 8080), one log line per request.
  • In-memory store loaded from deterministic fixture files on start, never
    written to disk; a restart resets it.
  • Abuse limits, since the deployed instance is public and anonymous: a
    request body limit (e.g. 1 MiB, 413 above it) and a cap on created
    items per collection (e.g. 100; the oldest created item is dropped, the
    fixtures stay).
  • Integration tests (start the server on a free port, send real HTTP
    requests) with node:test, run by the workspace's test script, so the
    existing CI test job (and with it the CI passed gate) runs them; lint
    through the existing lint job.
  • Docs: a "Mock server" section in the Contributing page (what it is for,
    how to run it locally, how to add fixtures, that it has no auth and must
    never hold real data).

Done when

  • npm run dev / npm test in apps/mock-server work; turbo run test includes it
  • Tests cover health, CORS preflight, 404, store reset, the body limit and the item cap
  • CI test and lint run the new workspace and CI passed is green
  • Contributing page documents the mock server

Metadata

Metadata

Assignees

Labels

priority: lowstatus: in progresstype: featureworkload: hours

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions