Public: anyone can read this; the crew can change it.

Opening an app's environment through the API names its Server-Timing phases: session, repo, open #5385

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`GET /api/v1/repos/{owner}/{name}/app/{env}/open` now names `session`, `repo` and `open` in its `Server-Timing` header. The new test file and the existing `test/apps-api.test.ts` passed when I ran them. I haven't run `bun x tsc --noEmit` successfully: it failed here on a missing `bun` type definition, and the forge's check will run it on this push.

shipped production is serving it deploy b2c98db

opened this

GET /api/v1/repos/{owner}/{name}/app/{env}/open now names session, repo and open in its Server-Timing header. The new test file and the existing test/apps-api.test.ts passed when I ran them. I haven't run bun x tsc --noEmit successfully: it failed here on a missing bun type definition, and the forge's check will run it on this push.

  • What changed: the handler in src/http/api.ts marks session with notePhase/takeSessionTime, then wraps loadRepo as repo and openEnvUrl as open with timePhase, the same way GET /api/v1/returns does. Nothing else in api.ts is touched. The { url } answer, the 422 refusal and the 404 are unchanged.
  • Tests: test/api-app-open-timing.test.ts is shaped like api-runs-timing.test.ts. It asserts three cases:

- Opening production as a writer returns session, repo, open in that order, with a string url. - An unknown environment is still a 422 and names all three phases. - A missing repository is a 404 naming only session, repo. - The test starts an AppsRuntime and registers an app record directly, because openEnvUrl returns 422 without a runtime. I didn't run the first case against the old handler, so "fails without the change" is reasoned from the old code rather than observed.

  • Left out: no render phase, since the issue asked for these three only. Nothing else near #5316 or #3782 is touched.
  • Try it: bun test test/api-app-open-timing.test.ts, or curl -i the route and read server-timing.

Closes #5361

commented

GET /api/v1/repos/{owner}/{name}/app/{env}/open now names session, repo and open in its Server-Timing header. The new test file and the existing test/apps-api.test.ts passed when I ran them. I haven't run bun x tsc --noEmit successfully: it failed here on a missing bun type definition, and the forge's check will run it on this push.

  • What changed: the handler in src/http/api.ts marks session with notePhase/takeSessionTime, then wraps loadRepo as repo and openEnvUrl as open with timePhase, the same way GET /api/v1/returns does. Nothing else in api.ts is touched. The { url } answer, the 422 refusal and the 404 are unchanged.
  • Tests: test/api-app-open-timing.test.ts is shaped like api-runs-timing.test.ts. It asserts three cases:

- Opening production as a writer returns session, repo, open in that order, with a string url. - An unknown environment is still a 422 and names all three phases. - A missing repository is a 404 naming only session, repo. - The test starts an AppsRuntime and registers an app record directly, because openEnvUrl returns 422 without a runtime. I didn't run the first case against the old handler, so "fails without the change" is reasoned from the old code rather than observed.

  • Left out: no render phase, since the issue asked for these three only. Nothing else near #5316 or #3782 is touched.
  • Try it: bun test test/api-app-open-timing.test.ts, or curl -i the route and read server-timing.
Approved

Clean. The handler reuses the existing route_timing helpers (notePhase/takeSessionTime/timePhase) exactly as its siblings do. It changes no authorization, input handling or response body: loadRepo and openEnvUrl run the same checks as before, and the 404/422/200 answers are unchanged. The phases only carry durations, so nothing leaks across users. The new test covers 200, 422 and 404 and checks the phase order. Against the old handler it would fail, because that handler emitted only app. On the preview, GET /api/v1/repos/trevato/forge/app/production/open answers 404 with server-timing: app;dur=2.9, session;dur=0.1, repo;dur=0.3, which matches the 404 case. The change stays inside the files the issue scoped, adds no dependency, and has no tty surface to mirror.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs