Skip to content

[Mock API] Experiment: mock endpoint on the website via Cloudflare (ADR Option 3B) #1078

Description

@karinamzalez

Summary

Summary

Build a throwaway, high-fidelity experiment of the integrated endpoint 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 a server-rendered endpoint on the website itself, with the site deploying to Cloudflare instead of GitHub Pages. Same origin as the docs, one deployment pipeline, and co-located with the specs, schemas, and sample-data generation the site already has.

This is the companion to the Option 3A experiment and uses the same rubric. The hypothesis to test: because the specs, schemas, and sample-data generation already live in the website, the surface area of this change may be smaller than "migrate hosting" makes it sound and it avoids keeping a second service in sync.

Data layer: same approach as the 3A experiment-- 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), falling back to the #1049 fixture/handlers only where it can't deliver. Note the generator reads files at build time, so even here samples likely need pre-generating rather than running per-request-- confirm.

Note this work is likely not wasted even if we choose 3A: the DNS migration to Cloudflare is happening regardless, and parallel GH Pages + Cloudflare deploys (e.g. beta.commongrants.org) are a useful stepping stone. If we don't choose this direction, it's a PR we close.

Acceptance criteria

Acceptance criteria

  • Astro configured for server output with the Cloudflare adapter, deployed to a Cloudflare preview, with existing static docs pages still rendering correctly
  • Mock opportunity endpoints served from the website itself, same origin as the docs (no CORS needed)
  • Swagger UI "Try it out" successfully calls the endpoint
  • 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); what breaks in the static build
    • 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: whether co-location makes staying in sync meaningfully easier than in the standalone shape, or whether both need the same build-time pre-generation
    • Deployment overhead: what changes about the publish pipeline; what the GH Pages → Cloudflare cutover would involve
    • 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
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions