Two related cleanups now that the shared test kit is published and s3proxy 4.2 adds fetchWeb(). Both remove code this repo currently hand-rolls.
1. Consume @forkzero/s3-website-test-kit (drop the in-repo shared-testing/)
This repo ships its own copy of shared-testing/. The load-test configs, scenarios, and utils now live in the published package @forkzero/s3-website-test-kit (already consumed by gmoon/s3proxy), so the two repos stay in sync instead of drifting.
npm install --save-dev @forkzero/s3-website-test-kit artillery
- Add an
.npmrc pinning the scope to public npm (in case a dev's global ~/.npmrc maps @forkzero to GitHub Packages):
@forkzero:registry=https://registry.npmjs.org
- Repoint the Makefile/test scripts at
node_modules/@forkzero/s3-website-test-kit/configs/… and …/scenarios/core/… (note scenarios split into core/ (portable) and s3proxy/ (e.g. health.yml)).
- Delete
shared-testing/.
This can be done now, independently of #2.
2. Adopt fetchWeb() in server.js (needs s3proxy 4.2)
server.js currently hand-rolls the exact Request → Response adaptation that s3proxy 4.2's proxy.fetchWeb() replaces:
// before
app.on(['GET', 'HEAD'], '/*', async (c) => {
const url = new URL(c.req.url)
const { stream, status, headers } = await proxy.fetch({
url: url.pathname + url.search,
method: c.req.method,
headers: Object.fromEntries(c.req.raw.headers),
})
return new Response(Readable.toWeb(stream), { status, headers })
})
// after
app.on(['GET', 'HEAD'], '/*', (c) => proxy.fetchWeb(c.req.raw))
fetchWeb throws the typed S3ProxyError on 404/403/416, so the existing XML app.onError keeps rendering error bodies exactly as today — no behavior change. Also drops the now-unused import { Readable } from 'node:stream'.
- Bump
s3proxy to ^4.2.0 in package.json.
- Replace the GET/HEAD handler as above.
- Keep the XML
onError and /health, /version routes unchanged.
Order
Do #1 anytime; #2 once s3proxy@4.2.0 is on npm.
Two related cleanups now that the shared test kit is published and s3proxy 4.2 adds
fetchWeb(). Both remove code this repo currently hand-rolls.1. Consume
@forkzero/s3-website-test-kit(drop the in-reposhared-testing/)This repo ships its own copy of
shared-testing/. The load-test configs, scenarios, and utils now live in the published package@forkzero/s3-website-test-kit(already consumed bygmoon/s3proxy), so the two repos stay in sync instead of drifting.npm install --save-dev @forkzero/s3-website-test-kit artillery.npmrcpinning the scope to public npm (in case a dev's global~/.npmrcmaps@forkzeroto GitHub Packages):node_modules/@forkzero/s3-website-test-kit/configs/…and…/scenarios/core/…(note scenarios split intocore/(portable) ands3proxy/(e.g.health.yml)).shared-testing/.This can be done now, independently of #2.
2. Adopt
fetchWeb()inserver.js(needs s3proxy 4.2)server.jscurrently hand-rolls the exactRequest → Responseadaptation that s3proxy 4.2'sproxy.fetchWeb()replaces:fetchWebthrows the typedS3ProxyErroron 404/403/416, so the existing XMLapp.onErrorkeeps rendering error bodies exactly as today — no behavior change. Also drops the now-unusedimport { Readable } from 'node:stream'.s3proxyto^4.2.0inpackage.json.onErrorand/health,/versionroutes unchanged.Order
Do #1 anytime; #2 once
s3proxy@4.2.0is on npm.