Public: anyone can read this; the crew can change it.
/explore keeps its filters in the address, so a filtered view can be sent and reloaded #16031
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/15970-explore-keeps-its-filters-in-the-address → main 0 commits fork
4 files
changed +41
−4
src/contract/openapi/routes/getApiV1Explore.ts +2 −2
| @@ -1,3 +1,3 @@ | ||
| 1 | import { limitTo, type Route } from "../shared.ts"; | |
| 1 | import { EXPLORE_QUERY, type Route } from "../shared.ts"; | |
| 2 | 2 | |
| 3 | export const route: Route = { method: "get", path: "/api/v1/explore", summary: "Explore apps and repositories", detail: "Explore apps and repositories; `q` takes words and `kind:`/`owner:` filters; answers { query, items, next_cursor } (an app item carries forks, ships, likes and updatedAt, the time of its last ship, not of its last push, null when never shipped) (`limit` 1 to 100 rows a page, default 30; next_cursor null on the last; a bad `limit`, `sort` or `kind` is a 422 naming the field); cursor from next_cursor; a bad cursor is a 422 `invalid_cursor`; the answer carries an ETag (cache-control private, no-cache; vary authorization, cookie) that changes when anything listed changes, and a repeat sending it in If-None-Match gets 304 with no body", auth: false, role: "anonymous", alsoStatus: [304, 422], query: { q: "string", cursor: "string", limit: limitTo(100), sort: "string", kind: "string" } }; | |
| 3 | export const route: Route = { method: "get", path: "/api/v1/explore", summary: "Explore apps and repositories", detail: "Explore apps and repositories; `q` takes words and `kind:`/`owner:` filters; answers { query, items, next_cursor } (an app item carries forks, ships, likes and updatedAt, the time of its last ship, not of its last push, null when never shipped) (`limit` 1 to 100 rows a page, default 30; next_cursor null on the last; a bad `limit`, `sort` or `kind` is a 422 naming the field); cursor from next_cursor; a bad cursor is a 422 `invalid_cursor`; the answer carries an ETag (cache-control private, no-cache; vary authorization, cookie) that changes when anything listed changes, and a repeat sending it in If-None-Match gets 304 with no body", auth: false, role: "anonymous", alsoStatus: [304, 422], query: EXPLORE_QUERY }; |
src/contract/openapi/routes/getExploreJson.ts +2 −2
| @@ -1,3 +1,3 @@ | ||
| 1 | import { limitTo, type Route } from "../shared.ts"; | |
| 1 | import { EXPLORE_QUERY, type Route } from "../shared.ts"; | |
| 2 | 2 | |
| 3 | export const route: Route = { method: "get", path: "/explore.json", summary: "The explore page as JSON", detail: "The rows /explore shows, for the same filter line (`q` words, or `kind`, `sort`, `updated`, `owner` and the other parameters); answers { query, filters, items, next_cursor } where `filters` names what the line set and each app item carries `score_parts` (forks, ships, likes, fresh, use, quiet, total); a word the explorer does not take is a 422 naming it; a private app appears only to a viewer who may read it", auth: false, role: "anonymous", alsoStatus: [304, 422], query: { q: "string", cursor: "string", limit: limitTo(100), sort: "string", kind: "string" } }; | |
| 3 | export const route: Route = { method: "get", path: "/explore.json", summary: "The explore page as JSON", detail: "The rows /explore shows, for the same filter line (`q` words, or `kind`, `sort`, `updated`, `owner` and the other parameters); answers { query, filters, items, next_cursor } where `filters` names what the line set and each app item carries `score_parts` (forks, ships, likes, fresh, use, quiet, total); a word the explorer does not take is a 422 naming it; a private app appears only to a viewer who may read it", auth: false, role: "anonymous", alsoStatus: [304, 422], query: EXPLORE_QUERY }; |
test/explore-openapi-filters.test.ts added +12
| @@ -0,0 +1,12 @@ | ||
| 1 | /** Both explore routes list every filter the page reads from the address (#15970). */ | |
| 2 | import { expect, test } from "bun:test"; | |
| 3 | import { EXPLORE_PARAMS } from "../src/actions/explore.ts"; | |
| 4 | import { route as json } from "../src/contract/openapi/routes/getExploreJson.ts"; | |
| 5 | import { route as api } from "../src/contract/openapi/routes/getApiV1Explore.ts"; | |
| 6 | ||
| 7 | test("the OpenAPI description of /explore.json and /api/v1/explore lists each filter parameter", () => { | |
| 8 | for (const r of [json, api]) { | |
| 9 | const named = Object.keys(r.query ?? {}); | |
| 10 | for (const p of [...EXPLORE_PARAMS, "q", "cursor", "limit", "since", "min_forks"]) expect(named).toContain(p); | |
| 11 | } | |
| 12 | }); |
new above
offline