Skip to content

[pull] main from jsr-io:main#94

Merged
pull[bot] merged 1 commit into
code:mainfrom
jsr-io:main
Jun 7, 2026
Merged

[pull] main from jsr-io:main#94
pull[bot] merged 1 commit into
code:mainfrom
jsr-io:main

Conversation

@pull

@pull pull Bot commented Jun 7, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

Part of the API service split ([design RFC
#1414](#1414)). **Step 4** of the
migration sequence: move the first read-only metadata GETs to the
workers-rs front.

## What this does

Ports `GET /api/stats` and `GET /api/metrics` from the Cloud Run compute
service to the `workers-rs` Worker:

- **Shared wire types.** Extracts `ApiStats`, `ApiStatsPackage`,
`ApiStatsPackageVersion`, and `ApiMetrics` into the shared, wasm-safe
`jsr_types` crate (new `jsr_types::api` module). The compute `api` crate
now re-exports them, so **both services serialize byte-identical JSON by
construction** (parity for these two endpoints).
- **Worker DB queries.** Implements `package_stats` and `metrics` in the
Worker via `tokio-postgres` over Hyperdrive (no `sqlx`). The SQL is kept
verbatim with `Database::package_stats` / `Database::metrics`.
- **Routing via axum.** The Worker routes with an `axum::Router`
(workers-rs `http` feature) instead of a hand-rolled `worker::Router`,
to stay consistent with the compute service's router-based structure.
`/api/stats` and `/api/metrics` are served by the Worker; the unmatched
fallback returns `501 Not Implemented`.

## Scope / non-goals

- The Worker is **not yet fronting prod traffic** — the `lb` routing
cutover is step 8.
- The compute side keeps serving these endpoints too; nothing is removed
until the cleanup step.
- Compute keeps using routerify (it builds on the hyper server + tokio
runtime, which don't compile to wasm). Converging compute onto axum is a
separate, optional refactor — not in this PR.
- The proxy-to-compute fallback (replacing the 501) and the larger
metadata GETs (`/api/packages`, `/api/users/:id`, package/scope/version
metadata) follow in subsequent PRs.

## Verification

- `cargo build --target wasm32-unknown-unknown --release` (workers-rs) —
green
- `cargo clippy --target wasm32-unknown-unknown -- -D warnings`
(workers-rs) — green
- `cargo fmt --check` (workers-rs) — green
- `cargo build -p jsr_types --target wasm32-unknown-unknown` (default
features, no sqlx) — green
- `cargo check -p registry_api` (compute, `SQLX_OFFLINE`) — green
@pull pull Bot locked and limited conversation to collaborators Jun 7, 2026
@pull pull Bot added the ⤵️ pull label Jun 7, 2026
@pull pull Bot merged commit 7ccc412 into code:main Jun 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant