Repository navigation
feat: move the API to a Cloudflare Worker and drop the Swift Lambda - #74
Merged
Merged
Conversation
- worker/: nzimages-api, a TypeScript port of the Swift Lambda for the Workers Free plan (custom domain nzimages-api.iolab.nz). Same /image and /collections responses, secret-header auth, DigitalNZ two-request pattern, strategy registry and converter signing, verified identical on 94 live records. Adds an ImageApi RPC entrypoint for the website's service binding and keeps every request under the Free plan's 50 subrequests. - 125 Vitest tests in workerd port the Swift suite. check-collections and count-collections replace CollectionTester and CollectionLister. - template.yaml now holds only the converter, its kill switch, the spike alarm, the cost topic and the budget. The Swift Lambda, HTTP API and API alarm are removed, as are the Swift sources, tests and build scripts. - CI runs the Worker's typecheck, tests and a bundle dry-run, and deploys only the converter stack. Workers Builds deploys the Worker. - collection-reviewer-web boots the Worker with wrangler dev instead of the Swift Lambda. Docs rewritten for the new layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Drop the DigitalNZ key when a redirect leaves its origin. - Escape ids taken from URL paths before building patterns. - Accept an HTTP-style comma string for the RPC exclude list. - Strip unclosed comments/scripts in one linear pass, so a malformed page can't blow the 10 ms CPU budget. - Reviewer dev script: pass wrangler only DIGITALNZ_API_KEY through a temp env file, signal its process group so workerd doesn't outlive it, and use port 8977 instead of wrangler's default 8787. - local_server.py defaults to 8788 with Worker instructions. Empty CONVERTER_SIGNING_KEY in .dev.vars.example. ADR 0001 notes the hosting move. renovate.json keeps its original formatting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- RPC image() accepts null options, and the comma-string exclude drops empty pieces like the HTTP path. - tooManyRedirects reports the hop where it stopped. - check-collections sniffs file type from the first chunk instead of downloading whole converted images. - Reviewer dev script passes its three Worker values as --var flags, which beat worker/.dev.vars and the environment, and cleans up on a crash. - CI fails the deploy if the converter's Function URL no longer matches JP2_CONVERTER_URL in worker/wrangler.jsonc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of moving NZ Images to the Cloudflare Free plan, with a free-tier AWS converter. Part 1 was #73.
What changes
worker/isnzimages-api, a TypeScript port of the Swift Lambda on the Workers Free plan. It is already deployed athttps://nzimages-api.iolab.nz.ImageApiRPC entrypoint for the website's service binding.src/http.tsfollows redirects itself and caps each request at 50 subrequests (the Free plan limit).check-collectionsandcount-collectionsreplace CollectionTester and CollectionLister.template.yamlkeeps only the converter, its kill switch, the spike alarm, the cost topic and the budget. The Swift Lambda, HTTP API and API alarm are removed, along with all Swift sources, tests and build scripts.collection-reviewer-webboots the Worker withwrangler devinstead of the Swift Lambda. Docs rewritten.Live checks on the deployed Worker
check-collectionsagainst the live Worker, comparing with the Lambda: 45/48 pass. The 3 failures are bugs carried over from Swift unchanged:scripts/smoke-test-access-control.sh --throttle: 200 with the secret, 401 without, and 429 from the iolab.nz WAF rule.Merging deletes the Swift Lambda and API Gateway. Nothing calls them any more, since the website moved to RPC.
🤖 Generated with Claude Code