Skip to content

Add a Cloudflare Worker that answers what a file cannot - #5

Draft
TimMonko wants to merge 1 commit into
cf/03-static-sitefrom
cf/04-worker
Draft

TimMonko wants to merge 1 commit into
cf/03-static-sitefrom
cf/04-worker

Conversation

@TimMonko

Copy link
Copy Markdown
Member

worker/ deploys the static site from scripts/build_site.py with
Cloudflare Workers static assets. Cloudflare serves a request that
matches a file without running any code, and those requests
are free and unmetered. Only a
miss runs src/index.js, which handles:

  1. /api/conda, the deprecated conda map. It shares its path with the
    api/conda/ folder, so it cannot be a file. Every released napari and
    plugin manager calls it, so it keeps its deprecation headers.
  2. Slugs that are not normalized (/api/manifest/Napari_Foo). manifest
    and shields always normalized; pypi and conda now do too, where they
    used to error.
  3. Unknown plugins: a JSON 404 instead of the old 500, and the
    "unavailable" badge for /api/shields.
  4. api.napari-hub.org/, which Vercel rewrote to /api/.
    About 2,670 plugin READMEs load badges from that host.

Tests run with node --test and a fake assets binding, so they need no
Cloudflare account. CI also bundles the Worker with a dry-run deploy.
Hostnames are left commented in wrangler.jsonc until the DNS zones are
confirmed.

Checked locally with wrangler dev over the full 5,105-file site:
content types, CORS, the landing page and every case above.

Ashley Anderson's cloudflare-poc branch proved the Cloudflare route
with R2 and a Python Worker; this keeps the same platform with less
code to maintain.


Stack created with GitHub Stacks CLI • Give Feedback 💬

worker/ deploys the static site from scripts/build_site.py with
Cloudflare Workers static assets. Cloudflare serves a request that
matches a file without running any code, and those requests
are free and unmetered. Only a
miss runs src/index.js, which handles:

1. /api/conda, the deprecated conda map. It shares its path with the
   api/conda/ folder, so it cannot be a file. Every released napari and
   plugin manager calls it, so it keeps its deprecation headers.
2. Slugs that are not normalized (/api/manifest/Napari_Foo). manifest
   and shields always normalized; pypi and conda now do too, where they
   used to error.
3. Unknown plugins: a JSON 404 instead of the old 500, and the
   "unavailable" badge for /api/shields.
4. api.napari-hub.org/<path>, which Vercel rewrote to /api/<path>.
   About 2,670 plugin READMEs load badges from that host.

Tests run with node --test and a fake assets binding, so they need no
Cloudflare account. CI also bundles the Worker with a dry-run deploy,
with read-only repository permissions.
Hostnames are left commented in wrangler.jsonc until the DNS zones are
confirmed.

Checked locally with wrangler dev over the full 5,105-file site:
content types, CORS, the landing page and every case above.

Ashley Anderson's cloudflare-poc branch proved the Cloudflare route
with R2 and a Python Worker; this keeps the same platform with less
code to maintain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant