Skip to content

[Mock API] Experiment: standalone Cloudflare Worker mock (ADR Option 3A) #1077

Description

@karinamzalez

Summary

Summary

Build a throwaway, high-fidelity experiment of the standalone Worker shape from the mock playground ADR so we can measure the actual surface area of the change before committing to a direction.

In this shape, the mock API is its own small Cloudflare Worker, deployed separately from the docs site. The docs site stays static on GitHub Pages and calls the Worker cross-origin.

This is one of two paired experiments (see companion ticket for Option 3B). The goal is not to productionize — it's to answer "what would we actually be signing up for?" for each option, using the same rubric, so we can pick one and move forward. Expect this PR to close unmerged if we choose the other direction.

Data layer: start from the website's existing sample-data generator (generateSchemaExample() in src/lib/schema/example-generator.ts, which runs openapi-sampler over the JSON schemas and powers the examples on the models pages) rather than the hand-authored fixture. Reuse keeps the mock in sync with the schemas by construction. Fall back to the #1049 fixture/handlers only where the generator can't deliver. Note the generator reads files at build time, so samples likely need pre-generating and bundling — confirm.

Dependencies: the Cloudflare account/token switch to the org account (separate ticket). A *.workers.dev URL is sufficient here; the custom domain (mock.commongrants.org) depends on the DNS migration and is out of scope.

Acceptance criteria

Acceptance criteria

  • A deployed Worker serving the opportunity endpoints, with CORS enabled
  • Swagger UI "Try it out" on a docs preview successfully calls the Worker cross-origin, documenting how the Worker's base URL gets into the rendered specs
  • Continuity check: the same record fetched from the browser, from a copied curl command, and from the TS SDK returns identical data
  • Findings written up against the shared rubric:
    • Surface area: what files, configs, and pipelines changed (rough LOC + list)
    • Data layer: how far the existing sample generator gets us against the [POC] #1034 Test A: client-side MSW mock playground #1049 review criteria — deterministic, list↔detail consistent, semantically representative, filterable/sortable, error responses — and what thin layer is needed on top for the gaps
    • Sync story: what keeps the mock in sync as the protocol changes, and what has to be hand-maintained
    • Deployment overhead: what a second publication pipeline actually requires (CI, secrets, release coordination)
    • Risks and unknowns discovered
  • Rough effort estimate for productionizing this shape
  • Timeboxed — if it runs long, stop and write up what's known

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions