-
Notifications
You must be signed in to change notification settings - Fork 2
chore: migrate to updated registry server API #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -11,10 +11,9 @@ export async function getRegistries(): Promise< | |||
| GithubComStacklokToolhiveRegistryServerInternalServiceRegistryInfo[] | ||||
| > { | ||||
| const api = await getAuthenticatedClient(); | ||||
| const registries = await api.getExtensionV0Registries({ | ||||
| const registries = await api.getV1Registries({ | ||||
| client: api.client, | ||||
| }); | ||||
|
|
||||
| if (registries.error) { | ||||
| console.error("[catalog] Failed to fetch registries:", registries.error); | ||||
| throw registries.error; | ||||
|
|
@@ -23,6 +22,7 @@ export async function getRegistries(): Promise< | |||
| if (!registries.data) { | ||||
| return []; | ||||
| } | ||||
| // console.log("registries", JSON.stringify(registries.data, null, 2)); | ||||
|
||||
| // console.log("registries", JSON.stringify(registries.data, null, 2)); |
Copilot
AI
Apr 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getServers() now calls getRegistries() and then getServersByRegistryName(), which results in multiple authenticated client creations and at least two network calls for every getServers() invocation. Since getServers() is used in several server routes/components, consider reusing a single authenticated client within getServers() (fetch registries and servers with the same client) and/or memoizing the default registry lookup per request (e.g., React/Next cache) to avoid repeated registry fetches.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| import { getRegistries, getServers, getServersByRegistryName } from "./actions"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { getRegistries, getServersByRegistryName } from "./actions"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { ServersWrapper } from "./components/servers-wrapper"; | ||||||||||||||||||||||||||||||||||||||||||||
| import { CATALOG_PAGE_SIZE } from "./constants"; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -20,12 +20,12 @@ export default async function CatalogPage({ searchParams }: CatalogPageProps) { | |||||||||||||||||||||||||||||||||||||||||||
| search: search || undefined, | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const [registries, { servers, nextCursor }] = await Promise.all([ | ||||||||||||||||||||||||||||||||||||||||||||
| getRegistries(), | ||||||||||||||||||||||||||||||||||||||||||||
| registryName | ||||||||||||||||||||||||||||||||||||||||||||
| ? getServersByRegistryName(registryName, paginationParams) | ||||||||||||||||||||||||||||||||||||||||||||
| : getServers(paginationParams), | ||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||
| const registries = await getRegistries(); | ||||||||||||||||||||||||||||||||||||||||||||
| const selectedRegistry = registryName ?? registries[0]?.name; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+25
|
||||||||||||||||||||||||||||||||||||||||||||
| const registries = await getRegistries(); | |
| const selectedRegistry = registryName ?? registries[0]?.name; | |
| const registriesPromise = getRegistries(); | |
| if (registryName) { | |
| const [registries, { servers, nextCursor }] = await Promise.all([ | |
| registriesPromise, | |
| getServersByRegistryName(registryName, paginationParams), | |
| ]); | |
| return ( | |
| <ServersWrapper | |
| servers={servers} | |
| registries={registries} | |
| nextCursor={nextCursor} | |
| /> | |
| ); | |
| } | |
| const registries = await registriesPromise; | |
| const selectedRegistry = registries[0]?.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no registry is available, getServerDetails() returns { error: Error, data: null, response: null }. The calling page only checks response?.status === 404, so this case will render an essentially empty detail page instead of failing fast. Prefer throwing (or returning a response/status that the page can handle) when the registry list is empty or the registries call errors, so this surfaces via error.tsx rather than silently continuing.