feat: add npm registry caching proxy #16

Merged
unkinben merged 1 commits from benvin/npm-remote into master 2026-04-27 20:30:18 +10:00
Owner

Summary

  • Add npm package type with metadata URL rewriting so dist.tarball URLs in package JSON are rewritten through the proxy
  • Single-remote design: metadata (mutable, TTL 600s) and tarballs (immutable, forever) handled by one remote — no separate files remote needed
  • Add .tgz content-type detection, example remote in remotes.yaml, full README section, and test coverage

Test plan

  • make test passes (179 tests)
  • npm install --registry http://localhost:8000/api/v1/remote/npm/ <package> installs successfully
  • Metadata cached as mutable with TTL, tarballs cached as immutable
  • dist.tarball URLs in served JSON rewritten to proxy URL
## Summary - Add `npm` package type with metadata URL rewriting so `dist.tarball` URLs in package JSON are rewritten through the proxy - Single-remote design: metadata (mutable, TTL 600s) and tarballs (immutable, forever) handled by one remote — no separate files remote needed - Add `.tgz` content-type detection, example remote in `remotes.yaml`, full README section, and test coverage ## Test plan - [x] `make test` passes (179 tests) - [x] `npm install --registry http://localhost:8000/api/v1/remote/npm/ <package>` installs successfully - [x] Metadata cached as mutable with TTL, tarballs cached as immutable - [x] `dist.tarball` URLs in served JSON rewritten to proxy URL
unkinben added 1 commit 2026-04-27 20:28:50 +10:00
feat: add npm remote type with metadata URL rewriting and caching
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
d585ab425c
- Add `npm` package type to config with no built-in mutable defaults;
  users set explicit mutable_patterns (e.g. ^(?!.*\.tgz$).*) and
  immutable_patterns (e.g. \.tgz$) in remotes.yaml
- Rewrite dist.tarball URLs in metadata JSON on the fly so tarball
  downloads pass through the same proxy remote instead of hitting
  npmjs.org directly
- Single-remote design: npm_files_remote points back to itself since
  both metadata and tarballs are served from registry.npmjs.org
- Add .tgz to _get_content_type (application/gzip)
- Add example npm remote to remotes.yaml
- Add npm proxy section to README covering remotes.yaml config,
  client setup (npm/yarn/pnpm), rewriting behaviour, and
  mutable vs immutable path table
- Add tests for mutable pattern matching, URL rewriting, content-type,
  scoped packages, cache miss, and tarball immutability
unkinben merged commit 25b85ddc92 into master 2026-04-27 20:30:18 +10:00
unkinben deleted branch benvin/npm-remote 2026-04-27 20:30:18 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#16